Split $tring into Parts and Paste output into multiple Column/Cells

Papa_Don

New Member
Joined
Jan 22, 2015
Messages
38
Hi group,

I have a column within a spreadsheet that contains email addresses. Each row can have one (1) email address or it can have multiple email addresses (occasionally as many as 5 or 6 email addresses). As an example, the spreadsheet could look like this:
ABCDEFG
tom.kennedy@company.com
StacyJohns@company.com; BrendaCobb@company.com; Jason.Anders@company.com; Robert.Morgan@company.com
Brenda.Freeman@company.com; Karen.Hazen@company.com

<tbody>
</tbody>

I need to create a macro that will:

1) if column A has only 1 email address, move that email to column B
2) if column A has multiple email addresses, break them apart and place the first email address in column B, the second email address in column C, the third email address in column D and so on.

The macro should make it look like this:
ABCDEFG
tom.kennedy@company.comtom.kennedy@company.com
StacyJohns@company.com; BrendaCobb@company.com; Jason.Anders@company.com; Robert.Morgan@company.comStacyJohns@company.comBrendaCobb@company.comJason.Anders@company.comRobert.Morgan@company.com
Brenda.Freeman@company.com; Karen.Hazen@company.comBrenda.Freeman@company.comKaren.Hazen@company.com

<tbody>
</tbody>

What would be the best way to do this? I've seen suggestions to use "Split", but truthfully I don't have a complete grasp of arrays and how they work. So I'm not sure how to code this. Therefore I am very open to your ideas and suggestions.

In advance, thanks for any help you can offer. I look forward to hearing from you.

Don
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I don't think you need a macro for this. If you click on the DATA tab in Excel, you will see a "Text to Columns" button. Highlight column A and click on that. Then select delimited, and input semicolon as your delimiter, then finish. You should get the results you want.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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