Donate SIGN UP

Excel VBA Help

Avatar Image
tpreece01 | 20:09 Thu 22nd Oct 2009 | Computers
0 Answers
I'm wondering if there's a way to show a message in Excel (2003) when a user selects a particular cell.

I've written the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address = "$A$1" Then MsgBox "A1 has been selected"
End Sub

But what I want is to add a lookup function in this along the lines of:

=LOOKUP(A1,'Sheet 2'!C101:C171,'Sheet 2'!D101:D171)

So that the Message Box displays the contents of Sheet 2, D101 when a user clicks on A1. I'm not sure how to format this code though.

Even better would be if there were a different function that the MsgBox that displayed the lookup without the user having to click OK - ie if a different cell is celected the lookup runs again, or the message is removed if a blank cell is selected.

Is this possible and can anybody help with my first attempt at Excel VBA programming?! Thanks for reading.
Gravatar

Answers

rss feed

Best Answer

Nobody has yet answered this question. Once some answers have been given, tpreece01 will be able to select one answer as the best. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
There are no answers available for this question.

rss feed

Do you know the answer?

Excel VBA Help

Answer Question >>