Creating hyperlink based on passed range

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
618
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I'm trying to create a hyperlink based on a passed range. The link location I can manage, but the destination sheet/range is giving me fits. :oops:

I can assign the destination sheet using the .Parent function, but I can't pair the sheet and range for anything! The function quits at setting the Range. I assume the final range needs to be Sheets(gnr.parent).Range(gnr) but that doesn't work.

What am I doing wrong??

Code:
Set shtLinkDest = gnr.Parent
  With shtLinkDest
    Set rngLinkDest = .Range(gnr)
  End With

I'm using Tim William's code below to create the hyperlink (excel - Create Hyperlink to sheet in cell VBA - Stack Overflow) but it never progresses that far.

Code:
cellHyperlink rngLinkLoc, _
              rngLinkDest, _
              CStr(rtsdata)

Thanks y'all!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Turns out that using gnr without specifying the sheet for the cellHyperlink function works just fine. However, I don't really understand why. I thought that without a sheet reference, the range could point to any sheet (usually the activesheet??) but the passed range implicitly knows which sheet it directs to. What am I misunderstanding?
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

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