So I'm working on learning arrays in VBA.
VBA does not treat arrays very nicely, and I found a .net implementation in VBA that seems to work better/cleaner. Great, let's use that!
So I start by making my sub, dimming the array, and setting it:
Sub ArrayTest()
Dim StorageArray as Variant
Set StorageArray = CreateObject("System.Collection.Arraylist")
Hurray, working array! Let's add items to it.
StorageArray.Add "Peter"
For i = 1 to 4
StorageArray.Add i
Next i
Works great!
Let's get items out of it.
For each Name in StorageArray
debug.print Name
Next
end sub
Everything's rosy up until here. Now I want to go a bit more advanced: I want to add multi-dimensional objects to the array, and I want to dumb the ENTIRE array all at once into Excel. This is where it breaks down.
StorageArray.Add "Peter", "Paul" yells at me for a non-specified syntax error. StorageArray.Add ("Peter", "Paul") continues to yell at me.
ShTest.Range("A1").value2 = StorageArray also yells at me. "Missing paramater does not have a default value. Paramater name: Parameters" is the error given.
I know at one point I could dump an entire array out into Excel like that, but I was building off of someone elses code that I no longer have access to, so I can't figure out what the difference is.
I'm willing to look into other array methods, but the reason I'm looking into this in the first place is I have a large (~70k lines) file that needs a table unpivoted. PowerQuery is THE textbook tool for doing this, however, I don't have access to it. Apparently SQL could also help, but my SQL knowledge isn't strong enough. A double loop works, but it takes literal hours to process, and I know it can be done in minutes. I suspected that most of the time is taken up by writing the data one line at a time to the results sheet, so I'm looking into arrays to speed things up massively.