假设我有以下VBS代码:
For Each cell in Sheet.UsedRange.Cells
If IsNumeric(cell) Then
i = i + 1
If i = 1 Then ' get the first occurrence of the cell in a row
' finish code
我希望得到连续数字的第一个单元格,忽略当前行中的剩余单元格,然后继续下一行。我知道它与存储当前行(cell.Row)的值有关,但我无法弄清楚条件。
非常感谢任何帮助。
答案 0 :(得分:1)
Sub findFristNumber()
Dim r As Integer, c As Integer
Dim cellValue
r = Sheet1.UsedRange.Rows.Count
c = Sheet1.UsedRange.Columns.Count
For i = 2 To r
For j = 1 To c
cellValue = Cells(i, j)
If IsNumeric(cellValue) Then
MsgBox cellValue
Exit For
End If
Next j
Next i
End Sub