indirect doesn't work in vba

blue333

Board Regular
Joined
Mar 19, 2009
Messages
64
hi

i have an array of strings that holds addresses of cell references. I originally tried

Dim CopyRangeArray() As String
ReDim CopyRangeArray(1 To MaxEntries)

for counter=1 to 100
... = Sheet3(CopyRangeArray(Counter)).Value
next counter

but it doesnt work. I can do this text to address conversion using INDIRECT in non-vba but not vba.

any suggestions?

thanks
 
If the array contains strings of range addresses like
$F$2:$L$13

Then when you use those to copy from, you must use the RANGE object, not CELLS.

The Cells object requires Row # and Column # or letter, like
Cells(row#,Column# or letter)
Cells(1,1) = Range("A1")
Cells(1,"A") = Range("A1")

You are using
Cells($F$2:$L$13)
That is invalid syntax.

Worksheets(NewWSName).Cells(CopyRangeArray(Counter)).Value = Sheet3(CopyRangeArray(Counter)).Value

Translated applying your array variable
Worksheets(NewWSName).Cells($F$2:$L$1).Value = Sheet3($F$2:$L$1).Value

Plus, you didn't even use Range OR Cells on the 2nd half.


It should be like this

Worksheets(NewWSName).Range(CopyRangeArray(Counter)).Value = Sheet3.Range(CopyRangeArray(Counter)).Value


thanks jonmo1. it works now. i appreciate your help!!!
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,214,808
Messages
6,121,681
Members
449,048
Latest member
81jamesacct

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