how do you refer to the text in a cell in VBA?

Machds42

Board Regular
Joined
Apr 23, 2007
Messages
54
I know that when referring to the text in a cell in excel I would write something like

INDIRECT(".....") etc

But if i have a cell with a name in it, and want excel to always copy the text in the cell, how do i write that in vba

e.g

Application.Goto Reference:=xxxxxx

cheers
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Say you have a range named MyName and A1 contains MyName:

Application.Goto Reference:=Range("A1").Value

will select that named range.
 
Upvote 0
Hi

I'm not sure I appreciate what it is you're asking but say you have a named range named "richard" which refers to cell D1 and you have cell A1 containing the text "richard" then you can return the value of D1 via this structure:

Code:
Msgbox Range(Range("A1").Value).Value
 
Upvote 0
I have a named range called "x"

Howver, depending on what i choose from a drop down list, the named range may change to something else, say "y", since i have more than one named range

I need to write a macro which will take me straight to the named range ("x" or "y" depending on which i choose).

Example

I have range A1:A10 named "Bob"
I have range B1:B10 named "Bill"

In C1 I have a drop down list, containing "Bob" and "Bill"

I choose Bob from the drop down list

I know want to write a macro that takes me to Bob in the sheet

So C1 contains the text of the name I need to find

Hence why i thought i might be able to use;

Application.Goto Reference:=then the reference to the text in the cell, as it is always changing
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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