1

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
1
  • 1
    You're missing some parentheses: Dim bigArray() As String Commented Jul 22, 2014 at 14:17

1 Answer 1

1

Arrays in Excel are declared using ()

Dim bigArray() As String
ReDim bigArray(0 To 1, 0 To 1) As String
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.