troubleshooting Question

Intersect, and refer to column by name

Avatar of lhutton
lhutton asked on
Microsoft OfficeMicrosoft ExcelVBA
8 Comments1 Solution90 ViewsLast Modified:
  1. With the intersect, how can I prevent the code from being activated if there is no Site? (The commented code affects the whole worksheet.)
  2. How can I refer to Selection.Offset(0, -1) by the column's name, Site?

Dim sSite As String
If Not Intersect(Target, tb.ListColumns("Variable").DataBodyRange) Is Nothing Then
' If Intersect(Target, tb.ListColumns("Variable").DataBodyRange) <> "" And Selection.Offset(0, -1) <> "" Then
    Cancel = True
    sSite = WorksheetFunction.Substitute(WorksheetFunction.Index(Range("Sites[[Base]]") _
    , WorksheetFunction.Match(Selection.Offset(0, -1), Range("Sites[[Site]]"), 0)), "*", "" & ActiveCell.Value & "")
    ThisWorkbook.FollowHyperlink (sSite)
End If
ASKER CERTIFIED SOLUTION
lhutton

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros