Creating a relative hyperlink

Good evening,
I would like to know how to create a relative hyperlink.
Actually, I have an Excel file on my desktop containing a sheet.
To simplify, I'll give you an example:
In cell A2 of my Excel file, I have a line that says "fruit list" and on my USB drive, I have a folder called "Fruits" containing: apples, bananas, oranges.
I want that by clicking on cell A2 of my Excel file on the line "fruit list" present on my desktop, I can directly access the content "apples" present on my USB drive.
The idea is to create a relative hyperlink so that, for example, if I change the location of my Excel file, it won't affect the folder on my USB drive and there won't be any error message.
I hope my explanation is clear. How could I do that? Thank you.
Sincerely

2 answers

  1. Contributor
    Hello,

    I don’t think you can modify a hyperlink created by insertion. Maybe in VBA?

    With the function, and the file in D:\tmp
    To address D:\tmp\ccm:
    absolute link:
    =HYPERLINK("D:\tmp\ccm";"fruits")
    relative link:
    =HYPERLINK(".\ccm";"fruits")
    . points to the directory of the file.

    .. points to the parent directory of the file’s directory:
    =HYPERLINK("..\ccm";"fruits") is therefore D:\ccm
    You can go up multiple directories in the tree with:
    ..\..\..\ etc

    eric

    By trying continuously, you eventually succeed.
    So the more it fails, the more chances you have that it will work. (the Shadoks)
    In addition to the thank you (yes, it’s done!!!), remember to mark it as resolved. Thanks
    1
    1. Hello Eric,

      Thank you for your help.

      To make sure I understood correctly: should I write these formulas in my Excel file or in VBA?

      Moreover, I am not a specialist in macros and VBA.

      Best regards.
      0
    2. Contributor
      Hello,

      it's a sheet formula.
      eric
      0
    3. Okay, thanks Eric.

      I'll try this in my Excel file and I'll come back here.
      0