ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   indirect addressing? a range of cells (https://www.excelbanter.com/excel-programming/318429-indirect-addressing-range-cells.html)

spindle

indirect addressing? a range of cells
 
Is it possible using VBA to store an address string in a cell and then
assign a value to the cell whose address is stored? Or is there a better way
to solve this problem? Say I have a series of cells whose names might be
ap1,ap2,ap3...ad1,ad2,etc. I would then select the appropriate named cell
based on VBA code which first builds the address string ap1 or ad2, etc and
uses this string to assign a value (say 600 or 900) to the right cell (ap1 or
ad2, etc).

Thanks,
Randy

Frank Kabel

indirect addressing? a range of cells
 
Hi
do you mean

dim rstr as string
rstr="ap2"
range(rstr).value="Test"

--
Regards
Frank Kabel
Frankfurt, Germany

"spindle" schrieb im Newsbeitrag
...
Is it possible using VBA to store an address string in a cell and

then
assign a value to the cell whose address is stored? Or is there a

better way
to solve this problem? Say I have a series of cells whose names might

be
ap1,ap2,ap3...ad1,ad2,etc. I would then select the appropriate named

cell
based on VBA code which first builds the address string ap1 or ad2,

etc and
uses this string to assign a value (say 600 or 900) to the right cell

(ap1 or
ad2, etc).

Thanks,
Randy



gocush[_28_]

indirect addressing? a range of cells
 
Here's a note of warning:
Don't use range names like "ad1" or "ap1" since these are actually cells:

Range("ad1") is the first cell in Col AD just to the right of range("ac1")
and just to the left of range("ae1").

If you try to name Range("B6") for example as "ad1", Excel will get confused.
"spindle" wrote:

Is it possible using VBA to store an address string in a cell and then
assign a value to the cell whose address is stored? Or is there a better way
to solve this problem? Say I have a series of cells whose names might be
ap1,ap2,ap3...ad1,ad2,etc. I would then select the appropriate named cell
based on VBA code which first builds the address string ap1 or ad2, etc and
uses this string to assign a value (say 600 or 900) to the right cell (ap1 or
ad2, etc).

Thanks,
Randy



All times are GMT +1. The time now is 10:00 PM.

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