Array initialization in Excel VBA - getting an error

On the microsoft website:

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

It says that I can initialize the array as follows:

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

But I get an error message:

 Compile error: Expected: end of statement 

And he points to an equal sign. I just copy-paste, what's wrong here?

+6
source share
1 answer

This will work in vb or vb.net, but not vba. You need to initialize this in two steps.

 Dim doubles doubles = array(1.5, 2, 9.9, 18) 
+7
source

Source: https://habr.com/ru/post/944611/


All Articles