0

I'm new to VBA and I'm trying to create a multidimensional array. Per MSDN, I have the following:

Sub answersArray()
  Dim answers (,) As String
End Sub

This gives me the error "Expected: expression" and highlights the comma in the declaration statement. What am I doing wrong?

1

1 Answer 1

3

That's not how you declare an array in VBA.

Dim answers(5,5) As String

would declare a 2-d array with bounds 0-5 and 0-5.

If you don't know the size at the time you dimension it, just use

Dim answers() As string

and then later you can use ReDim()

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I'll do that. Wasn't aware of the difference between VBA and VB.net
That are really only similar in syntax - fundamentally they are completely different languages.

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.