I have
dim buff(60000) as string
and three thousand elements are used, each with exactly 80 bytes of data.
What is the awesome way to plop that into range myRange and the 2,999 cells under it? Or the 59,999 cells under it, even if most are empty? IOW I want myRange to get buff(0), myRange.offset(1,0) to get buff(1), etc. By the way I don't want to hardcode the 3000 (though the 80 is okay).
If I go Range("myRange").Resize(100, 1) = buff
it loads the correct cells, but every single cell contains buff(0).
(BTW I'm just arbitrarily using 100 for discussion)
I can go Range("myRange").Resize(1, 100) = buff
but that loads cells to the RIGHT of myRange, not below it. I know, duh, but at least it gets what I want; I still have to transpose, a PITA, and besides I'll run out of columns if there's enough input.
Range("myRange") = buff
just loads one cell, with buff(0)
In case it matters, I can also have all of buff's contents in a variant or something else. I tried
Dim buff2(1, 60000) As String
Range("myRange").Resize(1, 100) = buff2
which of course loads to the right;
Range("myRange").Resize(100, 1) = buff2
oddly picked up 1 good value, skipped a cell, then 98 #N/A values. Very weird.
(Note: maybe I should have gone Dim buff2(1:1, 60000) As String?)
You know, I could go something likebut I hoped I could do better with .resize or another direct assignment.![]()
With Range("myRange") Do Until Len(buff(iRecordsRead)) < 1 .Offset(iRecordsRead) = buff[iRecordsRead] iRecordsRead = iRecordsRead + 1 Loop End With
Bookmarks