Converting CSV text in a single column, into multiple columns

  • Thread starter Thread starter Kerry M. Soileau
  • Start date Start date
K

Kerry M. Soileau

I've got string data in the first (A) column of a spreadsheet. Each string
consists of comma separated substrings. I'd like to distribute the
substrings out into their own columns, e.g., if An contains
"hi,there,my,name,is", I'd like to put "hi" into Bn, "there" into Cn, "my"
into Dn,"name" into En,"is" into Fn. It is easy to do this manually, but
when I use the Macro Recorder to get the code to do it, the code doesn't
work. Can anyone help?
Thanks,
Kerry Soileau
 
One way (manually):

Select your column. Choose Data/Text to columns... Select the
Delimited radio button. Click Next. check the Comma checkbox. Click
next. Put $B$1 in the destination box. click finish.


One way (macro):

Public Sub ParseCSV()
With Selection
.TextToColumns Destination:=.Offset(0, 1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=False, _
Semicolon:=False, _
Comma:=True, _
Space:=False, _
Other:=False
End With
End Sub

Select the strings to convert (one column at a time) and run the
macro.
 
Back
Top