You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
I need to know address when I change the value.
There's Change event in worksheet, but it tells the activecell address after I hit enter and the address is not the same as just changed.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo firstRun
MsgBox "Current Address: " & Target.Address(0, 0) & vbCrLf & _
"Last Address: " & rngLast.Address(0, 0)
firstRun:
'must be last
Set rngLast = Target
End Sub
This was written by someone in microsoft.public.excel.programming
This one was written by my "god father" or more "god son" Tom Ogilvy, I really have no idea about his age
Here it is
Option Explicit
Dim rngLast As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not rngLast Is Nothing Then
MsgBox "Current Address: " & Target.Address(0, 0) & vbCrLf & _
"Last Address: " & rngLast.Address(0, 0)
End If
Set rngLast = Target
End Sub