Prompting users with a message box on certain cells

T

tommy

I am looking for a macro to do the following:

As soon as a User clicks on cells B18 or B24 or B37

a message box should pop up with my message (I already have the message code)

I just need the code to tell it when a user selects one of the above
mentioned cells
 
J

John

Hi Tommy
Did you know you can get the same result with >Data>Validation>
goto Input message and type your message. Also you got >Insert>Comment.
Without a Macro
HTH
John
 
T

tommy

To All,
I'm sorry
I forgot to mention that Data Validation is not an option since I am already
using it as a drop down list on the mentioned cells
 
T

tommy

Sorry,
but I dont want to use Insert Comment or Data Validation

I want the message box to pop up since it forces the user to read and click OK
 
G

Gord Dibben

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const sINPUTS As String = "B18,B24,B37"
If Not Intersect(Target, Me.Range(sINPUTS)) Is Nothing Then
MsgBox "your message"
End If
End Sub

Right-click on the sheet tab and "View Code". Copy/paste into that module.

Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP
 
T

tommy

thanx, this worked

BUT, I need a total of 31 lines/sentences to complete my message

the last 7 lines are on the same line as the 7 previous lines

how do I extend the message box
 
G

Gord Dibben

What happened to....................?

" (I already have the message code) "

I suppose you could add a bunch of linefeeds like

MsgBox "this is the first line of the message" & vbCrLf _
& "this is the second line of the message" & vbCrLf _
& "this is the third line" etc.

Would be far easier to place the message in a textbox on a UserForm which
loads when the correct cell(s) are selected.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const sINPUTS As String = "B18,B24,B37"
If Not Intersect(Target, Me.Range(sINPUTS)) Is Nothing Then
UserForm1.Show
End If
End Sub

Users read the message then hit the close "x" on the UserForm


Gord
 

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