I use a vb script to reformat CSV I receive from a vendor on a daily basis. I've started receiving a new batch of fields (columns) that I need to concatenate AND insert separators between values. Currently, my tortured method is below:
objSheet.Range("X2:X" & lastrow).FormulaR1C1 = "=RC[5] & "";"" & RC[6] & "";"" & RC[7] & "";""& RC[8] & "";"" & RC[9] & "";"" & RC[10] & "";"" & RC[11] & "";"" & RC[12] & "";"" & RC[13] & "";""
However, this results in a whole lot of orphan semi-colons whenever a column is empty. I've tried TEXTJOIN like so:
objSheet.Range("X2:X" & lastrow).FormulaR1C1 = "=TEXTJOIN("";"",TRUE,RC[5]:RC[16])"
but that failed.
Can somebody provide an alternative method that won't end up creating entries like this?
;;;;subject5;;subject7;;;;subject11
I wrote an article a while back about parsing a CSV file prior to importing into Access, which should work similarly for your import into Excel. Check it out at: