Need VBA to prepare data in column to use text-to-column function

trevhill

Board Regular
Joined
May 27, 2009
Messages
93
Here's my problem.

I'm using a database software that exports results (in this case the results are industries & subindustries) into one cell. Example

cell A1:A5000

Food;

Meat;

Chicken;

Grower

Each cell has an industry, which is then followed by a semicolon and then a space. When I try to use Excel's built-in text to column feature, I can't get it to work unless I manually enter the cell, and delete the extra spaces between each entry (food; meat; chicken, etc.)

Here's the other probleam, not each row (data point) has the same amount of industries and subindustries. Some may be i) food; meat; chicken; grower and some are just ii) food; meat.

I"m looking for someone to help me draft the VBA code to manipulate the text in colum a, so that I can use the text to column feature.

Thanks for help,

T
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I couldn't get the code in the previous link to work (admittedly I'm weak at VBA).

Really my problem is deleteing the extra lines within each cell.

Current data:

Food;

Beverage;

Softdrinks

Next Desired Step:

Food;
Beverage;
Softdrinks

Next Desired Step

Food; Beverage; Softdrinks

At that point it can use the text to columns feature
 
Upvote 0
I think that I misunderstood. Is this in a single cell?

Food;

Beverage;

Softdrinks
 
Upvote 0
Try find>repalce, find what hold down alt and type 010, release alt key This will remove the line feed.

Then do you text to column
 
Upvote 0
Highlight the column. Select Text to Columns. Select Delimited>Next. Select>Other and in the box do ALT+Enter. Check the Box beside "Treat consecutive delimiter as one" Select Finish.

You should have Food; in 1 column, Meat; in the next Chicken: in the next
 
Upvote 0

Forum statistics

Threads
1,225,071
Messages
6,182,683
Members
453,132
Latest member
nsnodgrass73

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