How to open an array?

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

Parents Reply Children
  • Thanks. ReDim works.

    And may you also tell me what's wrong with the following?    

    Solved. That' ok

    ===================================================

    ReDim oWorkSheetName(1 To oWorksheetNum) As String

    For i = 1 To oWorksheetNum

    Set oWorkSheet = oExcel.Worksheets(i)
    oWorkSheetName(i) = oWorkSheet.Name

    Debug.Print oWorkSheetName(i)
    Next

    ===================================================

  • ===================================================ReDim [preserve] oWorkSheetName(1 To oWorksheetNum) As String

    For i = 1 To oWorksheetNum

    Set oWorkSheet = oExcel.Worksheets(i)
    oWorkSheetName(i) = oWorkSheet.Name

    Debug.Print oWorkSheetName(i)
    Next
    ===================================================

    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 ®