問題:For currentRow = 25 To rowCount
の後、残りのfor文は何も原因でスキップされ続けます。VBAでループが発生しないために
私は他の2つのForステートメントがこの問題のあるコードブロックの前にあり、それらのフォーマットはこれと同じで、両方ともうまくいきます。
Public Sub WeightB()
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String
sourceCol = 7
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
For currentRow = 24 To rowCount
currentRowValue = Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
Cells(currentRow, sourceCol).Select
Exit For
End If
Next
End Sub
私はFor loops being skipped without cause in VBAを参照しましたが、まだこれを理解できませんでした。
'For'ループの直前の' rowCount'の値は何ですか? – Bathsheba
行の数は「整数」ではなく「Long」型でなければなりません。また、セルを完全に修飾する必要があります。[VBAベストプラクティス - ワークシートを想定しない](http://stackoverflow.com/documentation/excel-vba/1107/vba-best-practices/9218/never-assume-the-worksheet #t = 201704280559226199101)。 –
私はMsgBoxのrowCountを試してみましたが、それは22です。 –