How to get the active cell address?

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
 
L

losmac

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top