Using hyperlink function in IF conditional cell formula

Mrock1

Board Regular
Joined
Oct 7, 2014
Messages
78
I have just tied to use the hyperlink function in an if formula in a cell. Essentially the formula if condition is if there is no value in another cell then hyperlink to that cell (I use the # prefix ) and if there is a value then use that value. In simple terms if is:

=If($A$1=“”, hyperlink(“#$A$1”, “Click here”), $A$1)

I will admit that the cell reference is a calculation to find an adjacent cell value and reference the target cell using an Address, Index, Match combination, but the formula above is a simplified version

The problem is that if there is no value in the target cell, the hyperlink works just fine. However, if there is a value, then the value is displayed in the formula cell but clicking in that cell produces a hyperlink error “Can’t open the file”. Empirically this suggests that there is somehow a residual but corrupted hyperlink associated with the cell. Does anyone know why this will be happening?

The only way I can see around this problem is to have two hyperlink functions for each of the IF true and false conditions to explicitly define the hyperlink for both outcomes like:

=if($A$1=“”, hyperlink(“#$A$1”, “Click here”), hyperlink(“#$A$1”, $A$1))

Frankly this is probably most appropriate as I don’t want the user to be able to enter a value in that cell but take them to the target cell where the value should be entered. So I’ve worked around my problem but the question is still there and I’d appreciate if anyone can explain this behaviour.

Thanks again.

Max
 
Using a simplified example, is this what you're looking for?
Book1
AB
1
2a1
3b2
4c3
5d4
6a1
7b2
8c3
9d4
10e 
Sheet1
Cell Formulas
RangeFormula
B6:B10B6=IFERROR(HYPERLINK("#B"&MATCH(A6,$A$1:$A5,0),INDEX($B$2:$B5,MATCH(A6,$A$2:$A5,0))),"")
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
FYI I use O375

Your formula is a great idea. I ended up creating a nested if condition with 2 explicit hyperlink functions for the true and false conditions, but hadn’t thought to use an iferror. My formula essentially uses the first if condition to result in a “” if the record in column A was found. If it is found then I do another if to make the same hyperlink jump location but display “Click get to update the value on row n” or the value that is on row n. But looking at your construct it may be a way to shorten tbe formula. I can’t look at it u til I get to work tomorrow but will definitely see if I can use your approach to achieve the outcome I want in a shorter formula.

Thanks for the help.

Max
 
Upvote 0
FYI I use O375
I'm gonna guess that the 7 is a typo and it should be 365. If you do as I suggested earlier then it shows under your user name on the left side of your posts so that anyone helping you can see without having to ask you in every thread.
While the formula that I've suggested here is good for any version of excel back to 2007 it is often the case that additional functions in newer versions of excel will allow for better answers. If people don't know which version you use they may assume incorrectly and not necessarily provide what could be the best answer for your actual version.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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