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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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