copy text from a cell to enter in macro

P

Peterzh193

having not found an adequate solution to
http://www.OfficeKB.com/Uwe/Threads...4?ArtID=#[email protected]



i am now asking if i can take the text/values from a cell and use them in the
macro?

for example i have in cell D4 the text/value "A4"

can a macro take the text from this cell?

i plan to make the cell A4 an activecell, for reasons i wont go into now i
cant simply range("a4").select and apply the macro from there, is this
possible?
 
R

Rick Rothstein

If D1 contains A4 and you want the contents of A4, just nest the Range
property calls...

With Worksheets("Sheet2")
MsgBox .Range(.Range("D4").Value).Value
End With

Note that you do not have to select either D4 or A4 (the cell it is
referencing) in order to do what you want. If, however, you wanted to
ultimately select A4 (the value in D4), you would just change the last Value
property call to a Select method call instead...

With Worksheets("Sheet2")
.Range(.Range("A1").Value).Select
End With
 
Top