PDA

View Full Version : Sleeper: Open Hyperlink File From Cell - Follow Hyperlink



dj44
12-10-2016, 06:45 PM
Hi folks,

Good Evening :)

Can any one shed light on why my hyperlink wont open

Click on Cell A1 open the hyperlink in Cell B1




If Not Intersect(ActiveCell, Range("A1:A6")) Is Nothing Then


ThisWorkbook.FollowHyperlink (ActiveCell.Offset(, 1).Value)



I made a hyperlink like this - it opens normally if i just click on it - but not when i try the other cell A click

=HYPERLINK("[C:\Users\DJ-Laptop\Desktop\FileA.xlsx]B1","Open")

It’s a very annoying issue - I don’t know how to make this open, I've researched on the internet and nothing seelms to work
Thank you

onlyadrafter
12-11-2016, 03:45 AM
Hello,

What do you have in the cells A1 and B1?

dj44
12-11-2016, 04:45 AM
Hello,

I have made cell A1 a blue colored cell.

In cell B1 the hyperlink word is Open and the address shows like this


=HYPERLINK("[C:\Users\DJ-Laptop\Desktop\FileA.xlsx]B1","Open")

It works when I click cell B1, but not when I click Cell A1

I would like to click A1 so that it opens the hyperlink in cell B1

Click A2 open hyperlink in B2 etc and so forth

snb
12-11-2016, 05:34 AM
Use a hyperlink in B1 instead of a hyperlinkformula

dj44
12-11-2016, 05:54 AM
Hello SNB,
i have 2 hyperlinks that I tested on, 1 with a formula and 1 just plain hyperlink that I made manually, I dont know why it doesnt open

I used the private selection change so when i click on A1 it whould open but no such luck yet

onlyadrafter
12-11-2016, 08:44 AM
Hello,

agree with snb, instead of formula in B1, just insert a hyperlink, you can still change the test display to show 'open'.

You can still use the Workbook selection change event to open the file in col B.

dj44
12-11-2016, 09:06 AM
Hi,

I made a normal hyperlink - so press A1 click and open Cell B2 hyperlink

17816

And this is the code



Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

On Error Resume Next
If Not Intersect(ActiveCell, Range("A1:B4")) Is Nothing Then


ThisWorkbook.FollowHyperlink (ActiveCell.Offset(, 1).Value)



End If

snb
12-11-2016, 09:41 AM
If the 'texttodisplay'<>'hyperlinkaddress'


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$G$16" Then ActiveWorkbook.FollowHyperlink Cells(16, 8).Hyperlinks(1).Address
End Sub

dj44
12-11-2016, 10:10 AM
Hi SNB,

Thank you It works for 1 cell address as you laid out.

So if I click on cell A1


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then ActiveWorkbook.FollowHyperlink Cells(1, 2).Hyperlinks(1).Address
End Sub

The hyperlink opens in B2


Now If I can just get it to work for all the hyperlinks in column B then that will be enough.
This is what I am trying - and tweaking




Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

On Error Resume Next
If Not Intersect(ActiveCell, Range("A1:B4")) Is Nothing Then ActiveWorkbook.FollowHyperlink(ActiveCell.Offset(, 1).Value).Hyperlinks(1).Address


End If
End Sub

snb
12-11-2016, 01:18 PM
Begin diving into the fundamentals of Excel & VBA before continuing this path.