ViggieSmalls
ViggieSmalls

Reputation: 73

expected array error for 2-D array

I'm trying to create a two dimensional dynamic array, but keep getting the error "Expected Array" when it comes to ReDiming the bigArray. Any input on why this is happening? Also any help on creating this 2D array would be appreciated.

Thank you

Sub Button2_Click()


Dim i As Integer, j As Integer
Dim Lastrow As Long
Sheets("3").Activate
Lastrow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
Sheets("4").Activate

Dim myArray As String
**Dim bigArray As String
ReDim bigArray(0 To 1, 0 To 1) As String**
j = 0


For i = 2 To Lastrow
    If Not IsEmpty(Sheets("3").Cells(i, 1).Value) Then
        myArray = Array(CStr(Sheets("3").Cells(i, 10).Value), CStr(Sheets("3").Cells(i, 20).Value))
        If UBound(myArr) > 1 Then
            ReDim Preserve bigArray(LBound(bigArray) To UBound(bigArray) + 1, 0 To 1) As String
        End If
        bigArray(UBound(bigArray), 0) = myArray(0)
        bigAray(UBound(bigArray), 1) = myArray(1)
    End If
Next i

End Sub

Upvotes: 1

Views: 977

Answers (1)

Ravi Yenugu
Ravi Yenugu

Reputation: 3898

Arrays in Excel are declared using ()

Dim bigArray() As String
ReDim bigArray(0 To 1, 0 To 1) As String

Upvotes: 1

Related Questions