ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy text from a cell to enter in macro (https://www.excelbanter.com/excel-programming/429611-copy-text-cell-enter-macro.html)

Peterzh193

copy text from a cell to enter in macro
 
having not found an adequate solution to
http://www.OfficeKB.com/Uwe/Threads/...GP05.phx .gbl



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?


Rick Rothstein

copy text from a cell to enter in macro
 
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

--
Rick (MVP - Excel)


"Peterzh193" <u52491@uwe wrote in message news:9765201eb2634@uwe...
having not found an adequate solution to
http://www.OfficeKB.com/Uwe/Threads/...GP05.phx .gbl



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?




All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com