An implementation of Visual Basic that is built into Microsoft products.
In Excel VBA, use the ActiveCell.Row and ActiveCell.Column properties to determine the row and column numbers of the currently selected cell.
Sub GetActiveCellPosition()
Dim RowNumber As Long
Dim ColumnNumber As Long
RowNumber = ActiveCell.Row
ColumnNumber = ActiveCell.Column
MsgBox "Row: " & RowNumber & vbCrLf & _
"Column: " & ColumnNumber
End Sub
For example, if the active cell is D5, ActiveCell.Row returns 5 and ActiveCell.Column returns 4.
You can also retrieve both values directly without declaring variables:
Debug.Print ActiveCell.Row
Debug.Print ActiveCell.Column
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin