Space in Sheet Title causing Reference Not Valid for Hyperlink

lakomitten11

New Member
Joined
Jun 21, 2017
Messages
7
The purpose of this code is to create a hyperlink to another sheet based off of the 'HyperlinkName' variable which is the last value in the equipment list. A new sheet has already been created with the exact same name as the 'HyperlinkName' variable. The code is creating the hyperlink properly, however when there is a space in the equipment name I will receive a Reference Not Valid error, then the sheet will open.

Code:
[/COLOR]Dim R As Range
    Set R = Cells(Rows.Count, 2).End(xlUp) 'last cell in Column B with data
    If Len(R.Value) > 0 Then Set R = R.Offset(1)
    R.Value = Range("j3").Value




       HyperlinkName = Sheet4.Range("j3").Value




    Sheets("Equipment List").Hyperlinks.Add Anchor:=R, Address:="", SubAddress:= _
    HyperlinkName & "!A1", TextToDisplay:=HyperlinkName
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi, try like this (additions in red):

Rich (BB code):
    Sheets("Equipment List").Hyperlinks.Add Anchor:=R, Address:="", SubAddress:= _ 
   "'" & HyperlinkName & "'!A1", TextToDisplay:=HyperlinkName
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

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