How to get the active cell address?

  • Thread starter Thread starter d
  • Start date Start date
D

d

How to get the active cell address?
eg. Click A1 on Excel sheet1 and VBA code get this active
cell value "A1" and display in A2 cell.

Thanks in advance.

d
 
Try it!

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim celAdr As String
Dim lRow As Long, pos As Long, i As Long

celAdr = Target.Address
lRow = Target.Row + 1

Do
pos = InStr(pos + 1, celAdr, "$")
If pos > 0 Then i = pos

Loop Until pos = 0

MsgBox Left(celAdr, i) & lRow

End Sub

losmac
 
Back
Top