View Single Post
 
Old 04-16-2020, 03:35 PM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Partly right. First I use Split to turn a string of space-delimited words into an array; I needed the array for only a few lines, one "paragraph", so I used a throwaway variable:
Code:
' Let's say vm contains "AR GA MC".  Then:
ar = Split(vm)
' Now ar(0) contains "AR", ar(1)="GA", ar(2)="MC"
But I'm not using that array to paste into a worksheet. Further down I tried to use ReDim like this:
Code:
ReDim ar(1 to rZ, 1 to cZ) 'max row and column
For jr = 2 to rZ
  ar(jr, 1) = Column1Value
  ar(jr, 2) = Column2Value
  ' ...and so on
  Next jr
Range(ows.Cells(1, 1), ows.Cells(rZ, cZ)).Value = ar
As I wrote in my original post, when I didn't Dim ar(), the VBA interpreter complained at compile time that the ReDim statement is invalid. When I declare ar(), it complains at execution time that the Split function is an invalid assignment.

After the question had languished here for a while, I gave up and posted it over at another forum. After I started getting answers over there I marked this one "solved" so as not to waste anyone's time here. Eventually someone there got me to try declaring ar() As String, and it worked! Still not sure why letting it stay Variant didn't work as well, but I'll keep it in mind.
Reply With Quote