Question Everything
Question Everything

Reputation: 2319

Initializing Array in Excel VBA - getting error

In the microsoft site:

http://msdn.microsoft.com/en-us/library/vstudio/wak0wfyt.aspx#BKMK_DeclaringAnArray

It says I can initialize an array like this:

Dim doubles = {1.5, 2, 9.9, 18}

But I'm getting error:

Compile error: Expected: end of statement

And it points to the equals sign. I'm merely copy-pasting, what's wrong here?

Upvotes: 6

Views: 6607

Answers (1)

glh
glh

Reputation: 4972

This would work in vb or vb.net but not vba. You need to initialise this in two steps.

Dim doubles
doubles = array(1.5, 2, 9.9, 18)

Upvotes: 7

Related Questions