May I know if there any method to open an array like that:
Dim y As Duoble
............
..........
y = 7 '(Y finally got something)
Dim x (1 To y) As String '<----- The problem is here
Unknown said:Dim y As Duoble
First, use Option Explicit. The VBA editor will catch typos like a mis-spelled name.
Unknown said:Dim x (1 To y) As String
You want an elastic array. Look up the Redim statement in VBA help. Hint: type Redim in your code. Leave the cursor inside the word. Press F1 to pop Microsoft VBA help.
Regards, Jon Summers LA Solutions
Thanks. ReDim works.
And may you also tell me what's wrong with the following?
Solved. That' ok
===================================================
ReDim oWorkSheetName(1 To oWorksheetNum) As StringFor i = 1 To oWorksheetNum
Set oWorkSheet = oExcel.Worksheets(i)oWorkSheetName(i) = oWorkSheet.NameDebug.Print oWorkSheetName(i) Next
===================================================ReDim [preserve] oWorkSheetName(1 To oWorksheetNum) As StringFor i = 1 To oWorksheetNumSet oWorkSheet = oExcel.Worksheets(i)oWorkSheetName(i) = oWorkSheet.NameDebug.Print oWorkSheetName(i) Next===================================================
ReDim [preserve] oWorkSheetName(1 To oWorksheetNum) As StringFor i = 1 To oWorksheetNum
You might want to add this 'Preserve' ( take away the square brackets [] ) option to retain the content of your array when you are re-dimensioning it to a larger or smaller range.
CADMinistrator ®