Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
newbie redim question
I need to create a 2-D _public_ array, and the size of the second dimension
needs to be based on a number from one of my procedures- so if I understand correctly, I need to dim the array at the top of a module to make it public, then redim it once I know what size the second dimension needs to be. At the top of my module, I have: Public ManualDataArray(1 To 2, 1 To 500) As Variant And within a sub, I try: ReDim ManualDataArray(1 To 2, 1 To MaxTestRows) I don't need to preserve anything, as I am redim'ing right before populating the array. Unfortunately, when I try to run my sub, I get: Compile error: Array already dimensioned. The help file only gives examples of redim'ing a one dimensional array, so I have no idea how to change the syntax so I can redim this array properly. I appreciate your help! Office 2003/Win2000 Keith p.s. I am making the array public because I need to access it from several different subs across several different modules. There may be a better way to set it up, and it may impact the suggested solutions to my problem...I just don't know the best way to set up my variables to ensure that (when appropriate) they can be accessed from any of my code within a workbook. -- The enclosed questions or comments are entirely mine and don't represent the thoughts, views, or policy of my employer. Any errors or omissions are my own. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
newbie redim question
If you want to make the array dynamic, don't start by dimensioning it
Public ManualDataArray -- HTH RP (remove nothere from the email address if mailing direct) "KR" wrote in message ... I need to create a 2-D _public_ array, and the size of the second dimension needs to be based on a number from one of my procedures- so if I understand correctly, I need to dim the array at the top of a module to make it public, then redim it once I know what size the second dimension needs to be. At the top of my module, I have: Public ManualDataArray(1 To 2, 1 To 500) As Variant And within a sub, I try: ReDim ManualDataArray(1 To 2, 1 To MaxTestRows) I don't need to preserve anything, as I am redim'ing right before populating the array. Unfortunately, when I try to run my sub, I get: Compile error: Array already dimensioned. The help file only gives examples of redim'ing a one dimensional array, so I have no idea how to change the syntax so I can redim this array properly. I appreciate your help! Office 2003/Win2000 Keith p.s. I am making the array public because I need to access it from several different subs across several different modules. There may be a better way to set it up, and it may impact the suggested solutions to my problem...I just don't know the best way to set up my variables to ensure that (when appropriate) they can be accessed from any of my code within a workbook. -- The enclosed questions or comments are entirely mine and don't represent the thoughts, views, or policy of my employer. Any errors or omissions are my own. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Newbie question | Charts and Charting in Excel | |||
Real Newbie newbie question | New Users to Excel | |||
newbie question | Excel Worksheet Functions | |||
Newbie Question - Subtraction Formula Question | Excel Discussion (Misc queries) | |||
newbie question | Excel Programming |