hyperlink doesn't work after ...

Tom2020

New Member
Joined
Aug 6, 2021
Messages
14
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
Hello all

I have an excel file with two sheets (sheetA, sheetB). From sheetA, A10, I have created an anchor to sheetB, E14. The value of both cells in two sheets is the same, a string like “FI_2005_first_05.pdf”.
Now I inserted a hyperlink from sheetA to E14 in the sheetB. If I click on, I will jump to E14 .... nothing special about that.

Now, imagine, I sort column, delete or add some rows to the sheetB, my hyperlink wouldn’t work at all.

Any Idea how to fix this issues? I would like to have some code(VBA) or combination formula to change >10000 anchors.

Thank you for helping me

tom
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Maybe you could use this? I've left just the cell("address" formula in some cells to show how this returns the cell position back into hyperlink.


Book1
ABCDE
2FI_2005_first_05.pdfFI_2005_first_05.pdf
3FI_2005_first_06.pdf[Book1]Sheet2!$A$8
4FI_2005_first_07.pdf[Book1]Sheet2!$A$7
5FI_2005_first_08.pdf[Book1]Sheet2!$A$6
6FI_2005_first_09.pdf[Book1]Sheet2!$A$5
7FI_2005_first_10.pdf[Book1]Sheet2!$A$4
8FI_2005_first_11.pdf[Book1]Sheet2!$A$3
Sheet1
Cell Formulas
RangeFormula
E2E2=HYPERLINK("#"&CELL("address",INDEX(Sheet2!$A$2:$A$9,MATCH(Sheet1!A2,Sheet2!$A$2:$A$9,0))),A2)
E3:E8E3=CELL("address",INDEX(Sheet2!$A$2:$A$9,MATCH(Sheet1!A3,Sheet2!$A$2:$A$9,0)))


Book1
A
1Names
2FI_2005_first_12.pdf
3FI_2005_first_11.pdf
4FI_2005_first_10.pdf
5FI_2005_first_09.pdf
6FI_2005_first_08.pdf
7FI_2005_first_07.pdf
8FI_2005_first_06.pdf
9FI_2005_first_05.pdf
Sheet2
 
Upvote 0
I’m very happy and satisfied with … thank you so much.

Bytheway, as already mentioned it is more than 10k hyperlinks to change, I’m wondering whether it is possible to run dynamically a VBA macro for these changes!

thx
 
Upvote 0
Hi Tom,

There's probably more efficient code than this, but this Clears & Refreshes the hyperlinks for the whole of Column E from Sheet1E2

Please try on a test copy before applying to your real sheet

VBA Code:
Dim rec As Range

Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

Set rec = Sheets("Sheet1").Range("E:E")
    rec.Select
        rec.ClearContents

        Sheets("Sheet1").Range("E2").Select
        ActiveCell.Formula2R1C1 = _
            "=IFNA(HYPERLINK(""#""&CELL(""address"",INDEX(Sheet2!R2C1:R9C1,MATCH(Sheet1!RC[-4],Sheet2!R2C1:R9C1,0))),RC[-4]),"""")"
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Formula2R1C1 = _
            "=IFNA(HYPERLINK(""#""&CELL(""address"",INDEX(Sheet2!R2C1:R9C1,MATCH(Sheet1!RC[-4],Sheet2!R2C1:R9C1,0))),RC[-4]),"""")"
        Columns("E:E").EntireColumn.AutoFit
        Sheets("Sheet1").Range("a1").Select
    
    Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
 
Upvote 0
many thanks.

with little problem, it works! ….

However, me and my manager were very frightened to make any decision. They are a lot of files.

… But, we have decided to leave the user with a possibility, especially if the anchor failed to show correct file name. The idea is to set this function (below) in an if-else-statement with Application.inputbox:

=HYPERLINK("#"&CELL("address",INDEX(Sheet2!$A$2:$A$9,MATCH(Sheet1!A2,Sheet2!$A$2:$A$9,0))),A2)

If “user click Cancel button of Application.inputbox, it exits”

Else “allow user to select a cell (e,g, A2) with an Application.inputbox to set anchor again!”

t
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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