假设我有以下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)有关,但我不能确定条件。
任何帮助都是非常感谢的。
发布于 2015-06-25 10:29:40
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 Subhttps://stackoverflow.com/questions/31039754
复制相似问题