excel vba获取行,来自selection.address的单元格值

For i = 1 To 20 '' select the cell in question Cells.Find(...).Select '' get the cell address CellAddr = Selection.Address(False, False, xlR1C1) Next 

以上是我的代码,用于search电子表格来查找特定的string,然后select它。 我想要使​​用Selection.Address来获取单元格的地址,在这种情况下,返回沿着R[100]C 。 有没有办法我可以拆分结果的行和列的值,所以我可以在代码中操纵它们? 我想,例如,添加14行到选定的单元格的行值。 我相信CellAddr将是一个Range对象,所以它可能工作我只是模糊的实现。

谢谢!

 Dim f as Range Set f=ActiveSheet.Cells.Find(...) If Not f Is Nothing then msgbox "Row=" & f.Row & vbcrlf & "Column=" & f.Column Else msgbox "value not found!" End If 

这是你想要的 ?

 Sub getRowCol() Range("A1").Select ' example Dim col, row col = Split(Selection.Address, "$")(1) row = Split(Selection.Address, "$")(2) MsgBox "Column is : " & col MsgBox "Row is : " & row End Sub