Reformatting comma delimited text with VBA

MichaelT

New Member
Joined
Sep 4, 2002
Messages
6
I have a spreadsheet that has some cells with comma delimited text (see below) in it that I am trying to break apart into a form that will be more suitable for Access entry. I have tried to do this with the Text to Column feature but it requires a lot of cuttting and pasting because there are so many rows. Is there a way to do this with VBA?

Thank you,
Michael Armstrong

Original form:
Text1 Item1 OtherItems
Text2 Item2, Item3, Item4 OtherItems
Text3 Item5, Item6 Other Items

convert to:
Text2 Item2 OtherItems OtherItems
Text2 Item3 OtherItems OtherItems
Text2 Item4 OtherItems OtherItems
Text3 Item5 OtherItems OtherItems
Text3 Item6 OtherItems OtherItems
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
AS long as there is a pattern or a distinct method to differentiate between which items go into certain columns/rows, then yes.

Is this a one-time operation or will you do the same thing on a routine basis?

It might be more time to code something if your conversion is really complicated then to do it manually.

From the details mentioned, I cannot tell how many items you have or how the columns repeat as you have a different number of elements in each. Is item1 not used at all? Is it deleted?

Lil
 
Upvote 0
Reply about reformatting:
1. This operation will be done repeatedly.
2. Any row with more than one item will have to be separated, so the text1 will not have to be done.
3. Each row may have different numbers of items that are comma-delimited.
Thanks. Michael
 
Upvote 0
I'd need to understand the difference between Item2, Item3 and what you mean by Otheritems?

Is it just something like:
Text1,data
Text2,data,data,data,data,data,data
Text3,data,data,data

email me @ larai@saturnee.com if you want to continue this offline. Its taking a long time for me to find threads I've responded to.
 
Upvote 0

Forum statistics

Threads
1,214,394
Messages
6,119,263
Members
448,881
Latest member
Faxgirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top