SelectionChange Event question

T

Ted M H

I want a simple message box that displays whenever I create a new selection
in a worksheet. The message box needs to display both the address of the
last selection and the address of the new selection. I have the following
solution:

Dim LastSelected As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox LastSelected & Target.Address
LastSelected = Target.Address
End Sub

This works fine except for the first time through, when LastSelected is
empty. How can I get the initial selection to display in the message box?

Many thanks.
 

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