Posted to microsoft.public.excel.programming
|
|
Another way with cell comments.
Yes it doew work! B7 is a merged cell range - mentioned in my opening post.
When I unmerged it and clicked on B7 the msgbox came up. Should there be a
dim line? How to reference it in the code lines?
"Tom Ogilvy" wrote:
worked fine for me.
This as well:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$7" Then
MsgBox Title:="Definition", Prompt:="The name of the measure.", _
Buttons:=vbOKOnly
ElseIf Target.Address = "$B$8" Then
MsgBox Title:="Something", Prompt:="Something else.", _
Buttons:=vbOKOnly
ElseIf Target.Address = "$C$5" Then
MsgBox Title:="Something1", Prompt:="Something else1.", _
Buttons:=vbOKOnly
End If
End Sub
Which was copied right out of the email and pasted into the sheet module.
Perhaps you have events disabled. To aid in debugging your problem, you can
put this in a general module and call it from the tools = Macros menu
Public Sub TurnOnEvents()
Application.EnableEvents = True
End Sub
--
Regards,
Tom Ogilvy
"Phil Hageman" wrote in message
...
Tom, Would you clarify something for me, when the user clicks on B7, the
message box should come up??? I have this code in the VBA sheet for the
worksheet it operates in. For some reason it is not working. Thanks,
Phil
"Tom Ogilvy" wrote:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$7" Then
MsgBox Title:="Definition", Prompt:="The name of the measure.", _
Buttons:=vbOKOnly
End If
End Sub
worked fine for me. For multiple cells, you could do
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$7" Then
MsgBox Title:="Definition", Prompt:="The name of the measure.", _
Buttons:=vbOKOnly
ElseIf Target.Address = "$B$8" then
MsgBox Title:="Something", Prompt:="Something else.", _
Buttons:=vbOKOnly
ElseIf Target.Address = "$C$5" Then
MsgBox Title:="Something1", Prompt:="Something else1.", _
Buttons:=vbOKOnly
End If
End Sub
This could also be done with a case statement
Case Target.Address
Case "$B$7"
Case "$B$8"
Case "$C$5"
End Select
--
Regards,
Tom Ogilvy
"Phil Hageman" wrote in message
...
Hi Tom,
Thanks for your reply. Here are the two Subs for this worksheet. The
first
works okay, but the MsgBox Sub does not. Where am I wrong? Also, to
add
the
MsgBox code for other cells, do I simply copy the code (like for B7)
and
change the cell address and MsgBox prompt...?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
' When user updates percentage in cell AV17, todays date (NOW)
' is automatically populated into cell AV18.
If Target.Address = "$AV$21" Then
Application.EnableEvents = False
Range("AV22").Value = Format$(Now, "mm/dd/yy")
Errorhandler:
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$7" Then
Application.EnableEvents = False
MsgBox Title:="Definition", Prompt:="The name of the
measure.", _
Buttons:=vbOKOnly
Errorhandler:
Application.EnableEvents = True
End If
End Sub
"Tom Ogilvy" wrote:
Possibly using the selectionchange event.
would this system work when the cell is locked and protection
invoked?
if you allowed the user to select locked cells.
http://www.cpearson.com/excel/events.htm
for information on events.
--
Regards,
Tom Ogilvy
"Phil Hageman" wrote in
message
...
One problem with complex (very numerous cells) with comments is
that
as
the
user moves the cursor through the worksheet, comments keep popping
up -
can
be quite an annoyance. Is there another way? - user clicks on a
cell,
box
comes up on screen with text, user clicks in the text box and
text
box
disappears. The click cells are not data cells, only title cells.
Also,
would this system work when the cell is locked and protection
invoked?
For example: merged cell range B7, user clicks cell B7, text box
comes
up
with text: "Person Responsible", user clicks somewhere in the text
box
and
it
disappears.
|