View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Message box to pop up if a particular value is entered

Assumes A1:B3 does not have merged cells.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim msg as String
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("A1:B3")) Is Nothing Then
msg = ""
Select Case LCase(Target)
Case "admin"
msg = "You may edit data only"
Case "manager"
msg = "You have editing data and modify content"
Case "co-ordinator"
msg = "Please contact extension 1453 for more information"
End Select
If msg < "" Then
MsgBox msg
End If
End If
End Sub

Right click on the sheet tab and select view code. Paste in code similar to
the above.

--
Regards,
Tom Ogilvy

"Neil Goldwasser" wrote in
message ...
Hi! I was wondering if it is possible to write a macro so that if any of

the
words "admin", "manager" or "co-ordinator" are entered into any of the

cells
A1:B3, then a message box will pop up saying "Your current user status

allows
editing". It would be great if it would work if any of those three words

are
put in, but if it can only look out for one particular word, "admin" would

be
enough.

Ideally (and this really would be perfect!) it would be great if the macro
could still look at cells A1:B3, but that it would have different messages
depending on which key-word is entered. e.g.
- If "admin" is entered it would display "You may edit data only"
- If "manager" is entered it would display "You have editing data and

modify
content"
- If "co-ordinator" is entered it would display "Please contact extension
1453 for more information"
Can anybody think of a way of doing this? (I am a bit of a Visual Basic
novice, but can follow instructions!)

Many thanks in advance, Neil Goldwasser