Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Message box to pop up if a particular value is entered



"Norman Jones" wrote:

Hi Neil,

I put the code in the module behind Sheet1; I selected Sheet2 and defined
the name ModificationRights to refer to cells A1:A10 (Insert | Name |
Define ...); I populated the newly named range on Sheet2 with some first
name (Anne, Ben, Carol...).
Returning to Sheet1, entering any of the names from the Sheet2 named range
caused a "Your Group Message!" msgbox to appear.

Assuming that the name is a workbook level name, it should not matter where
the named range is within the workbook.

---
Regards,
Norman



"Neil Goldwasser" wrote in
message ...
Thanks Norman! It's working now!

One quick question though - I have discovered that it will only work for
me
if that set of named cells is on the same sheet, i.e. the values that come
under the "ModificationRights" name are also on the sheet with the macro
in
it. I had previously been putting all the named cells that I will use in
the
drop-down lists etc... in a different sheet, to keep things "tidy". Is
there
a way that it will let me hide the names in a different sheet?

I was also wondering if there is a simple way of adding to the code so
that
I could have several groups, each with their own message.
E.g. "ModificationRights" would show "You may edit data and modify
content"
"DataEditingRights" would show "You may edit data only"
"ReadOnlyRights" would show "You only have read-only access and may not
edit
data"


Sorry if I'm being a pain, but this will pay off big time in the future!
Many thanks, Neil Goldwasser



"Norman Jones" wrote:

Hi Neil,

I inadvertently used the Worksheet_SelectionChange event.

Change this to:
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:B3")) Is Nothing Then
Select Case Target.Value
Case "admin":
MsgBox "You may edit data only"
Case "ModificationRights":
MsgBox "You may edit data and modify content"
Case "co-ordinator":
MsgBox "Please contact Neil on extension " & _
"1453 for more Information "
Case Else
If Not IsError(Application.Match(Target.Value, _
Range("ModificationRights"), 0)) Then
MsgBox "Your Group Message!"
End If
End Select
End If

ws_exit:
Application.EnableEvents = True

End Sub

If I then defined (via Insert | Names) a range (say, J:10) as
ModificationRights, then typing any entry from the ModificationRights
range
brought up the message: "Your Group Message!" .

My sub was intended purely for demo purposes and it is unlikely that you
would also want additionally to test for the "ModificationRights" string
(see the 2nd Case)

---
Regards,
Norman



"Neil Goldwasser" wrote in
message ...
Hi again! Thankyou both for your suggestions. Unfortunately though I
cannot
get either method to work. I grouped together a list of usernames under
the
name "ModificationRights", one of those being "ngoldwasser". However,
when
I
typed "ngoldwasser" into one of the cells A1:B3, it didn't work as
planned.

I'm sure it is something I am doing, but here is what happens:

With Bob's method I receive a syntax error, and the "select case..."
and
"case not intersect..." lines appear in red. I put this code in the
worksheet_change event.

With Norman's method nothing happens if I type in ngoldwasser. I tried
typing in "admin" as well, and no message box popped up until I clicked
bak
on the cell a second time. I had put this code in as a separate
worksheet_selection change event.

Can anyone tell me what I'm doing wrong please?
Many thanks, Neil Goldwasser



"Norman Jones" wrote:

Hi Neil,

Or did you mean something like:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:B3")) Is Nothing Then
Select Case Target.Value
Case "admin":
MsgBox "You may edit data only"
Case "ModificationRights":
MsgBox "You may edit data and modify content"
Case "co-ordinator":
MsgBox "Please contact Neil on extension " & _
"1453 for more Information "
Case Else
If Not IsError(Application.Match(Target.Value, _
Range("ModificationRights"), 0)) Then
MsgBox "Your Group Message!"
End If
End Select
End If

ws_exit:
Application.EnableEvents = True

End Sub


---
Regards,
Norman



"Neil Goldwasser" wrote in
message ...
Thanks Norman, I knew it would be something embarrassing! I'd tried
everything else, but not that one. Cheers.

Would there also be a way of naming cells, so that I could group
together
all the users who, for example, I will allow modification rights, as
one
name, e.g. "ModificationRights"?

I tried the following, but it is looking for "ModificationRights" as
the
value, and I don't know how to alter the code to allow the range of
values
that come under the name "ModificationRights" instead:

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:B3")) Is Nothing Then
Select Case Target.Value
Case "admin":
MsgBox "You may edit data only"
Case "ModificationRights":
MsgBox "You may edit data and modify content"
Case "co-ordinator":
MsgBox "Please contact Neil on extension 1453 for
more
information"
End Select
End If

ws_exit:
Application.EnableEvents = True


Any chance that you might be able to solve this one as well please?

Thankyou, Neil Goldwasser



"Norman Jones" wrote:

Hi Neil,

but is there a quicker way, something along the lines of
Case "co-ordinator" "IT team":
MsgBox "Please contact extension 1453 for more
information"

Indeed there is. and you are only a whisker (or a comma!) away.

Simply separate the case items with a comma:

Case "Manager1", " Manager2", "Mamager3", ..."Manager20"
MsgBox "Please contact extension 1453 for more
information"


---
Regards,
Norman



"Neil Goldwasser" wrote
in
message ...
Hi Norman! Thanks for the explanation. I have now sandwiched both
sets
of
code between the
"Sub Worksheet_Change(ByVal Target As Excel.Range)" line and the
"End Sub" line
and it is working really well.

Sorry if it was a really simple question, but I am a novice, and
if
I
didn't
ask I would never know. I'm learning more all the time now
though.

My racing mind has now thought up a new question though. At the
moment,
one
of my sections of code is:
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:B3")) Is Nothing Then
Select Case Target.Value
Case "admin":
MsgBox "You may edit data only"
Case "manager":
MsgBox "You may edit data and modify content"
Case "co-ordinator":
MsgBox "Please contact Neil on extension 1453 for
more
information"
End Select
End If

ws_exit:
Application.EnableEvents = True

This allows three different messages for each of the three
different
"roles". If new roles, or new people came into the team, is there
a
quick
way
of adapting the code so that, for example, the message "Please
contact
extension 1453 for more information" would show for more than one
person?

I realise that I could keep adding cases, e.g.
Case "admin":
MsgBox "You have edit data only"
Case "manager":
MsgBox "You may edit data and modify content"
Case "co-ordinator":
MsgBox "Please contact Neil on extension 1453 for
more
information"
Case "IT team"
MsgBox "Please contact Neil on extension 1453 for
more
information"
and so on...

but is there a quicker way, something along the lines of
Case "co-ordinator" "IT team":



Can you change this to happen when any cell is selected instead of typing
admin or anything else into a cell?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message needed if incorrect Date Of Birth (DOB) entered Craig Excel Worksheet Functions 5 January 27th 10 08:24 PM
Lookup Entered Value and return message TKD Excel Worksheet Functions 4 January 7th 09 04:45 PM
Create error message if number entered is greater than previous ce Joe Lewis Excel Discussion (Misc queries) 2 July 25th 08 01:59 AM
formula to show the message that number already entered Eliane Excel Worksheet Functions 1 November 21st 07 04:59 AM
How to give an error message if a cell value entered is larger than permitted Colin Hayes Excel Discussion (Misc queries) 7 May 16th 07 02:39 PM


All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"