Parse Delimited String to Rows in VBA

  • Hi there,


    I'm sure there's an answer to this that I simply don't know the search terms to discover, so my apologies in advance if it's a dumb question.


    I currently have a function which grabs a csv file from a variable URL, saves it to a temporary directory and then imports it neatly and delimited into a new sheet. If possible though, I'd love to just do the whole process in VBA and skip the saving and opening steps.


    I have got as far as xmlhttp-ing the csv into a string, which is working perfectly. My dilemma now is that I haven't the foggiest idea how to parse that string (delimited by spaces) into rows. The closest I've come to an answer is automating Text to Columns on my string and then transposing the resulting columns to rows, but that just seems clunky, and I'm wondering if there's a more elegant method I can deploy.


    Strings that will be passed to this function are never more than 365 entries long, but can be any value less than that.


    Any pointers, solutions or general guidance would be much much appreciated!

  • Re: Parse Delimited String to Rows in VBA


    thanks for the heads up - I need to learn how to use arrays, of which I remain shamefully ignorant.


    One question on that front - I'm assuming that given the variable number of entries per string, I'll be working with dynamic arrays. Do I need ultimately to ReDim this to a particular number of entries (ie 1 to 365) or can it remain unspecified?

  • Re: Parse Delimited String to Rows in VBA


    example:
    cells(1,1).resize(ubound(split("textstring",vbcrLf))+1)=worksheetfunction.transpose(split("textstring",vbcrLf))
    columns(1).TexttoColumns , ......