Assign hyperlink to existing shape based on current column

dunthank

New Member
Joined
Nov 12, 2010
Messages
1
Hello,

I have searched for a long time but have not found a way to do this, either in Excel proper or with VBA. I need a way to construct a hyperlink address dynamically in real time and assign that link to a shape on the worksheet.

I have a workbook with links to specific (dated) columns on category detail sheets in the workbook. I have a "Summary Page" button on each of the category worksheets. I need to automatically attach a hyperlink, with the address of the current column and row 4 on the Summary Page, to the button on the category page.

As an example, a hyperlink on the Summary Page in Cell S15 links to Vendor Payments Due sheet, Cell S5 (a totals cell). On the page is a shape button. I need the hyperlink in the shape button to return to Summary Page!S4 in the example.

I haven't found a solution yet - any help?

TIA
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I believe this will give you a near solution:

Code:
Option Explicit

Sub AddConditionalHyperlink()
    
    Dim sAddress As String
    Dim sColumn As String
    Dim sSubAddress As String
    Dim shp As Shape
    
    Set shp = ActiveSheet.Shapes("Rectangle 2")   'Define a shape
    sAddress = shp.TopLeftCell.Address   
    sColumn = Split(Range(sAddress).Address(, , xlR1C1), "C")(1)    'Get column number of top left cell of shape
    sSubAddress = "Summary!" & Cells(4, CLng(sColumn)).Address(0, 0)    'for current column and row 4
    ActiveSheet.Hyperlinks.Add Anchor:=shp, Address:="", SubAddress:=sSubAddress

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,225
Members
448,877
Latest member
gb24

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