Consulting

Results 1 to 10 of 10

Thread: Sleeper: Open Hyperlink File From Cell - Follow Hyperlink

  1. #1
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location

    Sleeper: Open Hyperlink File From Cell - Follow Hyperlink

    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  2. #2
    Hello,

    What do you have in the cells A1 and B1?
    ---------------
    Hope this helps
    ---------------

    Have been away for a very long time,
    but am popping back again (now and then).

  3. #3
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Use a hyperlink in B1 instead of a hyperlinkformula

  5. #5
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  6. #6
    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.
    ---------------
    Hope this helps
    ---------------

    Have been away for a very long time,
    but am popping back again (now and then).

  7. #7
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    Hi,

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

    File.jpg

    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  8. #8
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    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

  9. #9
    VBAX Mentor
    Joined
    Feb 2016
    Location
    I have lived in many places, I love to Travel
    Posts
    413
    Location
    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
    Cheers for your help

    dj

    'Extreme VBA Newbie in progress - one step at a time - like a tortoise's pace'


  10. #10
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Begin diving into the fundamentals of Excel & VBA before continuing this path.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •