Thread
:
Message box to pop up if a particular value is entered
View Single Post
#
5
Posted to microsoft.public.excel.programming
Neil Goldwasser
external usenet poster
Posts: 38
Message box to pop up if a particular value is entered
Many, many thanks to everyone that has helped me with this - you don't know
how much I appreciate it!
I have one more novice question though, if I may ask. I had already inserted
a Worksheet_Change code for that worksheet, as follows:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rTarget As Range
Dim rCell As Range
Set rTarget = Intersect(Target, Range("Supported_By_2"))
If Not rTarget Is Nothing Then
For Each rCell In rTarget
If rCell.Value = "** N/A **" Then
Application.EnableEvents = False
rCell.Offset(0, 1).Value = "N/A"
MsgBox "Cell " & rCell.Offset(0, 1).Address(False,
False) & " has automatically changed to N/A because a " & "second support
plan was not selected"
Application.EnableEvents = True
End If
Next rCell
End If
End Sub
(And again, many thanks to JE McGimpsey,
and Bob Phillips
for helping me construct that one!)
The problem is that when I added a second worksheet change macro, I received
an error message saying
"Compile error:
Ambiguos name detected: Worksheet_Change"
I'm sure it is a question that only a novice like myself could ask, but how
can I have more than one worksheet_change macro running in the same worksheet
(though functioning on different cells)? Ideally, both of these functions are
useful. I am hoping it is a case of just renaming the codes somehow to have
two different names, but when I had a go they both stopped working. Would
somebody please be able to advise me on how to alter the code to have more
than one macro running. Then if I am brave I might even try adding a third
bit later on to see if I've learned it - and won't need to pester everyone
:-)
Many thanks, Neil Goldwasser
"Tom Ogilvy" wrote:
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
Reply With Quote
Neil Goldwasser
View Public Profile
Find all posts by Neil Goldwasser