Intersect & Hyperlink

D

DonJ_Austin

I have had the following code working for some time. I am now adding a
hyperlink in a cell on the same sheet, but OUTSIDE the Named Range
"EntryCells". When I click on the link, I get an error msg "Method
'Intersect' of object '_Global' failed" and the debugger takes me to the "Set
iSect ..." line in the routine below.

Since I am clicking on a cell with no intersection inside the specified
range, I do not understand why I am not falling through the code with iSect =
Nothing. I can click on any *other* cell (without a link) outside that range
and nothing happens (which is correct).

I have found that if I 'long click' on the link and then separately click
(regularly) on it, the link is taken without the code problem. This makes no
sense and I cannot expect the users to understand or remember that.

Is there some mysterious connection between Intersect and hyperlinks on a
given worksheet ?


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim iSect As Range

If Target.Cells.Count = 1 Then
Set iSect = Intersect(ActiveCell, Range("EntryCells"))
If iSect Is Nothing Then
Range("EntryPromptDisplay") = ""
Exit Sub
Else
Sheets("WorkData").Range("EntryPromptLookup") = Cells(Target.Row, 5)
Range("EntryPromptDisplay") =
Sheets("WorkData").Range("EntryPromptLookup").Offset(0, 1)

End If
End If

Set iSect = Nothing

End Sub

Thank you for any help.
 
B

Barb Reinhardt

I think I'd change this line

Set iSect = Intersect(Target,Range("ENtryCells"))

I don't see why the AcitveCell would be different from the target here, but
who knows.
 
D

DonJ_Austin

Excellent ! Wonderful. Thank you.

I had spoken with several colleagues and most had not used such code /
methods enough to recommend anything.

On another point, I am running into one of those pesky IF tests that should
pass but doesn't. Forum would not work for actual debug assistance. Will
pay for help. How can I contact you or a referral consultant, if you have
one ?

- Don Jarrell
 

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

Similar Threads


Top