VBA using a formula in text to display

Jimbola

Board Regular
Joined
Jun 23, 2010
Messages
60
I am trying to set the Hyperlink texttodisplay property in VBA to a formula to return a cell value from a different sheet using INDRECT, the code I am using is;

Code:
TextToDisplay:="=INDIRECT(""'"" & R6C1 & ""'!A1"")"

The formula will go into cell B6 so "R6C1" refers to A6.

But this does not return anything, the cell contains the correct link but appears empty. How can I correct the formula, ideally I would like to use Relative References. Thanks.
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi Jimboola,

First, thanks for teaching me something new ! I didn't know you could put a dynamic formula into Hyperlink TextToDisplay.. I thought it was fixed text ! :)

But in terms of your specific problem, when using R1C1 references in an INDIRECT() function you must add the 2nd parameter ,FALSE otherwise INDIRECT assumes you are using normal A1 style references. ie
Code:
[COLOR=#333333]TextToDisplay:="=INDIRECT(""'"" & R6C1 & ""'!A1"",FALSE)"[/COLOR]

And of course, for consistency, you might need to change the !A1 to !R1C1 to get the desired result once using relative references.

Cheers,

Warren K.
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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