每个循环都有一个这样的
:Dim rCell as range
Dim Searchrange as range
Set Searchrange = wss.Range("B12:B36") 'where wss is a defined worksheet
For Each rCell in SearchRange
'do some stuff
'get the row number of the worksheetrow rCell is currently refering to
Next rCell
如何从wss.
当前持有值的原始工作表(rCell
)中获取行号?
答案 0 :(得分:2)
我可以想象有2种不同的“行号”:
Searchrange
的行数示例:
Dim SearchRange As Range
Set SearchRange = wss.Range("B12:B36") 'where wss is a defined worksheet
Dim rCell As Range
For Each rCell in SearchRange
'Absolute row number in the worksheet
Debug.Print rCell.Row 'returns 12, 13, 14, … 36
'Row number relative to the SearchRange
Debug.Print rCell.Row - Searchrange.Row + 1 'returns 1, 2, 3, … 25
Next rCell