Worksheet_SelectionChange

G

Guest

I am using the following macro to run whenever B2 is selected:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address <> "$B$2" Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
MsgBox ("hi")
Application.EnableEvents = True
End Sub

The macro works just fine; click on B1 and the macro runs.

B1 contains a hyperlink. The click also causes the hyperlink to be followed
(simultaneously??).

Is there anyway I can force the macro to execute completely before the
hyperlink gets followed?
 
J

Jim Cone

Hello GS,
You could put a fake hyperlink in the cell.. blue colored font with an underline.
Then at the end of your Sub, you could add code to duplicate the hyperlink action,
maybe an Application.GoTo.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Gary''s Student" <[email protected]>
wrote in message
I am using the following macro to run whenever B2 is selected:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address <> "$B$2" Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
MsgBox ("hi")
Application.EnableEvents = True
End Sub

The macro works just fine; click on B1 and the macro runs.
B1 contains a hyperlink. The click also causes the hyperlink to be followed
(simultaneously??).
Is there anyway I can force the macro to execute completely before the
hyperlink gets followed?
 
J

Jim Cone

Actually, you could have a real hyperlink in the cell, just link it back
to itself... Cell B2 hyperlinked to Cell B2.
Jim Cone


Hello GS,
You could put a fake hyperlink in the cell.. blue colored font with an underline.
Then at the end of your Sub, you could add code to duplicate the hyperlink action,
maybe an Application.GoTo.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Gary''s Student" <[email protected]>
wrote in message
I am using the following macro to run whenever B2 is selected:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address <> "$B$2" Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
MsgBox ("hi")
Application.EnableEvents = True
End Sub

The macro works just fine; click on B1 and the macro runs.
B1 contains a hyperlink. The click also causes the hyperlink to be followed
(simultaneously??).
Is there anyway I can force the macro to execute completely before the
hyperlink gets followed?
 

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