Conditional Hyperlink (macro) based on cell content

Ariful Islam

New Member
Joined
Feb 17, 2017
Messages
8
I want to create a Hyperlink (macro) based on cell value Sheet1!A1, where Sheet1!A1 contained formula and is always numeric. This is noted that others Sheets like Sheet2, Sheet3, Sheet3 etc. are always hidden.

e.g. Sheet1!A1=2 Go To Sheet2,
Sheet1!A1=3 Go To Sheet3,
Sheet1!A1=4 Go To Sheet4, etc.

Please someone help me.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try:

=HYPERLINK("#Sheet"&A1&"!B2","Go to Sheet"&A1)

where B2 is the cell on the target sheet you want to go to.
 
Upvote 0
Solution
Code:
    v = Sheets("Sheet1").Range("A1").Value
    Sheets("Sheet17").Range("A11").Formula = "=HYPERLINK(""#Sheet" & v & "!B2"",""Go to Sheet" & v & """)"

or

Code:
    v = Sheets("Sheet1").Range("A1").Value
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
        "Sheet" & v & "!B2", TextToDisplay:="Go to Sheet" & v
 
Upvote 0

Forum statistics

Threads
1,215,547
Messages
6,125,461
Members
449,228
Latest member
moaz_cma

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