I admit I'm still learning the mechanics of building large-set arrays in memory, then writing the resulting data out to the worksheet all at once at the end.
I've written a macro that builds a one-dimensional array in memory
Dim MyArr as Variant, NR as Long
Redim MyArr (1 to 1)
NR=1
'Large macro that builds the dataset and adds a new value, but for example:
MyArr(NR) = "1,5,7,12,26,27,49000,36.22"
NR=NR+1
Redim Preserve MyArr(1 To NR)
Over simplified, of course. End result, MyArr in memory has 68722 rows and each row is unique.
Question - how do I write MyArr out to G2:G68723 in one swoop?
I've tried:
Range("G2").Resize(UBound(MyARR)).NumberFormat = "@"
Range("G2").Resize(UBound(MyARR)).Value = MyARR
..but this seems to just write out the FIRST value from MyArr into all those rows. Instead the 68722 unique strings I've built, I get MyArr(1) over and over. So I think I'm close, but no cigar.
Extra Credit - the REAL goal is to split this array into 8 columns, parsing by the commas. I've tried:
Range("G2").Resize(UBound(MyARR), 8).Value = Split(WorksheetFunction.Transpose(MyARR), ",")
and
Range("G2").Resize(UBound(MyARR), 8).Value = WorksheetFunction.Transpose(Split(MyARR, ","))
Thanks in advance.
Bookmarks