Bri*_*ian 10 excel vba excel-vba
For i = 1 To 20
'' select the cell in question
Cells.Find(...).Select
'' get the cell address
CellAddr = Selection.Address(False, False, xlR1C1)
Next
Run Code Online (Sandbox Code Playgroud)
以上是我搜索电子表格以查找特定字符串然后选择它的代码.我想获取单元格的地址Selection.Address,在这种情况下,返回的内容R[100]C.有没有办法可以将结果拆分为行和列值,以便我可以在代码中操作它们?我想,例如在所选单元格行值中添加14行.我相信CellAddr将是一个Range对象,所以它可能工作我只是模糊实现.
谢谢!
San*_*osh 14
这是你想要的 ?
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
Run Code Online (Sandbox Code Playgroud)
Tim*_*ams 11
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
127660 次 |
| 最近记录: |