Use string cell address from a Excel cell VBA

ojhawkins

New Member
Joined
Nov 17, 2011
Messages
39
Hi all,

I have a cell that has the string of a cell address in it say Cell A1 has the string B2

How can I in VBA look at this cell and use the text inside as a range the same as the INDRIECT function.

Also can the cell I am looking at for the string be set as a Dim so if the contents change the new string cell address will be used?

Cheers,
O
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hello,

How about:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> a()<br><SPAN style="color:#00007F">Dim</SPAN> rngAddress <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>rngAddress = Range("A1").Value<br><br>Range(rngAddress).Select<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
See if this is the sort of thing you mean.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> UseCellValueAsAddress()<br>    <SPAN style="color:#00007F">Dim</SPAN> Addr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <br>    Addr = Range("A1").Value<br>    MsgBox "The value in cell " & Addr & " is: " & Range(Addr).Value<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Hello,

How about:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> a()<br><SPAN style="color:#00007F">Dim</SPAN> rngAddress <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>rngAddress = Range("A1").Value<br><br>Range(rngAddress).Select<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Perfect thank you!!!!!

I swear I tried this, obviously not.

Cheers,
O
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,610
Members
449,174
Latest member
ExcelfromGermany

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