Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynaminc multi dimensional array problem

Status
Not open for further replies.

ysommer

Programmer
Feb 26, 2001
45
Hi, I am trying to build a routine that will track each chart in a workbook and put it into a multi dimensional array that will have for each chart its name and its location.
This is the code:

For i = 1 To Worksheets.Count - 1
Worksheets(i).Select
For Each objChart In ActiveSheet.ChartObjects
intChartCount = intChartCount + 1
ReDim Preserve ChartArray (intChartCount, 1)
ChartArray(intChartCount, 0) = objChart.Name
ChartArray(intChartCount, 1) = Worksheets(i).Name
Next objChart
Next i
For Each cht In Charts
intChartCount = intChartCount + 1
ReDim Preserve ChartArray(intChartCount, 1)
ChartArray(intChartCount, 0) = cht.Name
ChartArray(intChartCount, 1) = cht.Name
Next cht

I am all the rime getting an error msg "subscript out of range" on the redim preserve line in the second time it reaches it.

Any ideas?

Thanks,
Yoel


 
As far as I know only the last index of the array can be redimmed.
 
The ReDim Preserve instruction is valid only for the last dimension of the array.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top