Click hyperlink in selected range

FariAb

New Member
Joined
Jul 20, 2022
Messages
13
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi everyone! I am trying to create a macro that filters a sheet based on a certain value, then select a cell that contains a hyperlink and click on that hyperlink that leads to another sheet. I've already managed to achieve the first part but the hyperlink part isn't working, does anyone know how it could be done? Under these lines I'll copy the code I currently have and color the part that I have issues with. Thank you in advance.

Rich (BB code):
Sub FilterBasedOnCellValueAnotherSheet()
    Dim category As Range
    Dim LR As Long
    With Worksheets("Result")
        Set category = .Range("B3")
    End With
    With Worksheets("Summary")
        With .Range("B3:M300")
            .AutoFilter Field:=1, Criteria1:=category, VisibleDropDown:=True
        End With
    LR = Range("B" & Rows.Count).End(xlUp).Row
    Range("L3:L" & LR).SpecialCells(xlCellTypeVisible).Select
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    End With
   
   
End Sub
 
Last edited by a moderator:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
The following code line selects one or more visible cells starting from the 3rd row. So, it will always follow the hyperlink address of the cell on the first visible (filtered) row (if there is a hyperlink in that cell).

VBA Code:
Range("L3:L" & LR).SpecialCells(xlCellTypeVisible).Select

Do you get an error on the indicated code line OR is it just following the wrong hyperlink? What is the exact issue?
When there are multiple rows filtered by the selected category, which row you'd like to use with the Follow method? The first one, the last one?
 
Upvote 0
The following code line selects one or more visible cells starting from the 3rd row. So, it will always follow the hyperlink address of the cell on the first visible (filtered) row (if there is a hyperlink in that cell).

VBA Code:
Range("L3:L" & LR).SpecialCells(xlCellTypeVisible).Select

Do you get an error on the indicated code line OR is it just following the wrong hyperlink? What is the exact issue?
When there are multiple rows filtered by the selected category, which row you'd like to use with the Follow method? The first one, the last one?
Hi, it's not following the link, the sheet the link leads to doesn't activate. Only one row is selected when the macro runs, so only one link has to be followed.
 
Upvote 0
I am able to use the code and it does exactly what it is supposed to do - activates the worksheet that the hyperlink leads to.

Can you check the hyperlink of that single cell to make sure that it is not leading to the same worksheet with the data (since there is no error as I can understand)? This is the only thing I can think of. I built the exact structure with Result and Summary worksheets, and also a couple of other sheets as the targets of hyperlinks. Then I created the hyperlinks by selecting the A1 cell of each target worksheet, and it works without problem.
 
Upvote 0
I am able to use the code and it does exactly what it is supposed to do - activates the worksheet that the hyperlink leads to.

Can you check the hyperlink of that single cell to make sure that it is not leading to the same worksheet with the data (since there is no error as I can understand)? This is the only thing I can think of. I built the exact structure with Result and Summary worksheets, and also a couple of other sheets as the targets of hyperlinks. Then I created the hyperlinks by selecting the A1 cell of each target worksheet, and it works without problem.
It still won't work, it may be a problem with my Excel, I'll make sure to check it out, thank you!
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top