2016-07-15 8 views

答えて

0

CountAを使用して行全体が空であるかどうかを確認します。

Function FirstEmtpyRow(startRow As Long) As Long 

     Do 
      startRow = startRow + 1 
      If startRow = rpws.Count Then Exit Function 

     Loop Until WorksheetFunction.CountA(Rows(startRow)) = 0 

     FirstEmtpyRow = startRow 

    End Function 
1
Dim startRow As Long 
Dim i As Long 
Dim lastRow As Long 
Dim sh As Worksheet 


startRow = 2 'Set first row to check 
Set sh = ThisWorkbook.Worksheets("Sheet1") 

lastRow = sh.Cells(sh.Rows.Count, "A").End(xlUp).Row 

For i = startRow To lastRow 
    If sh.Cells(i, 1) = "" Then 
     MsgBox "First empty row: " & i 
     Exit For 
    End If 
Next i 

する必要がありますが、このような何かをしようとしたことがありますか?

注:最後の行が空の場合は表示されません。

2

これは何か?

function FindFirstEmpty(i as long) 

while cells(i,1).value <> "" 
    i = i + 1 
wend 

FindFirstEmpty = i 

End function 

どのように行を始めるかによって異なります。

0

あなたは.END(xlDown)を使用することができますが、すぐに次のセルが空白ではないか、あなたはそれをスキップできることに注意する必要があります。

dim rw as long, nrw as long 
rw = 6 
with worksheets("sheet1") 
    with .cells(rw, "A") 
     if IsEmpty(.Offset(1, 0)) then 
      nrw = rw + 1 
     else 
      nrw = .end(xldown).offset(1, 0).row 
     end if 
    end with 
end with 

debug.print nrw 
関連する問題