excel vba getting the row,cell value from selection.address

后端 未结 2 819
一整个雨季
一整个雨季 2021-02-19 15:58
For i = 1 To 20

  \'\' select the cell in question
  Cells.Find(...).Select

  \'\' get the cell address

  CellAddr = Selection.Address(False, False, xlR1C1) 



Next
         


        
相关标签:
2条回答
  • 2021-02-19 16:16

    Is this what you are looking for ?

    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
    
    0 讨论(0)
  • 2021-02-19 16:31
    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
    
    0 讨论(0)
提交回复
热议问题