I am trying to create an excel workbook that will automate a reconciliation process and I came across an issue that I can't overcome.
The initial input file is a CSV file that is comma delimited. The problem is that some of the entries have extra comma so when I do text to columns some of the cells have incorrect content. The next cell after first column has text in it so I am trying to find a way to use it as delimiter. Here are how entries look:
First row: a, b, c, d (always delimited with commas hence separate part in code) Second row (in 90% of cases): a, b, c, d Second row (in 10% of cases): a1, a2, b, c, d
B in the above line is a text and has quotes so looks like this "b".
Is there any way to adjust text to column to make it work properly?
Here is the code I have put together so far:
Sub ExampleSplit1()
Range("A1").TextToColumns _
Destination:=Range("A1"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
Semicolon:=False, _
Comma:=True, _
Space:=False, _
Other:=False, _
OtherChar:="-"
Range(Range("A2"), Range("A2").End(xlDown)).TextToColumns _
Destination:=Range("A2"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
Semicolon:=False, _
Comma:=True, _
Space:=False, _
Other:=False, _
OtherChar:="-"
End Sub
I want the final result to look as follows: