VBA insert Hyperlinks to another sheet

Bearlord

New Member
Joined
Jan 2, 2013
Messages
23
Hello =) I'm new to VBA

I want to make a worksheet with a list of some sheets (within the same workbook) that are hyperlinks to those sheets.

Example: I have sheet named "Summary" where I have a list of the rest of the sheets in the same workbook. The list shows the names of the worksheets and i want to add a link so that when i click on the sheet's name, it sends me to that sheet. There are also other cells with important information about that sheet next to the cell containing the sheet's name (and that should be a link). The other information is already there, working fine. My only problem is the hyperlink in the sheet's name.

I've tried doing this :

Code:
SUMARY.Cells(lastRow + 1, 1).FormulaR1C1= "=HYPERLINK(" & SheetName & "!A1" & "," & SheetName & ")"

And a multitude of combinations related with the quote marks. I just can't make it work.

SheetName, lastRow and SUMARY are all previously defined and working fine (finding the last row, and obtaining the sheet's names)

If I don't use variables it works perfectly

Code:
SUMMARY.Cells(lastRow + 1, 1).FormulaR1C1 = "=HYPERLINK(""Sheet1!A1"",""Sheet1"")"

So the problem, I believe, is related with the use of nested quotation marks... any ideas on how to use this?

Thanks in advance for any help =)

--
Bear:confused:
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hello Bearlord, you were definately on the right track and this should help you. Now also, I included the workbook name (which you will have to change), which allows you to jump between worksheets if needed to.

I placed Sheet2!A1 in cell A1 and I got this result in A2 (you can move the resulting hyperlink to destination of your choice.

Code:
Sub createhyper()

Set a = Sheets("Sheet1")

a.Range("A2").Formula = "=HYPERLINK(""[Creating Hyperlinks.xlsm]" & a.Range("A1") & """, ""Sheet1"")"

End Sub
 
Upvote 0
GRTorres Thank you so much!

That's exactly what I was trying to do. I really mixed up with the quotation marks xD I was quite puzzled and couldn't figure it out. Again, thanks for your help ^^
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,819
Members
449,469
Latest member
Kingwi11y

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