Converting CSV text in a single column, into multiple columns

  • Thread starter Kerry M. Soileau
  • 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
 
J

J.E. McGimpsey

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top