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:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[/TR]
[TR]
[TD]tom.kennedy@company.com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]StacyJohns@company.com; BrendaCobb@company.com; Jason.Anders@company.com; Robert.Morgan@company.com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Brenda.Freeman@company.com; Karen.Hazen@company.com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[/TR]
[TR]
[TD]tom.kennedy@company.com[/TD]
[TD]tom.kennedy@company.com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]StacyJohns@company.com; BrendaCobb@company.com; Jason.Anders@company.com; Robert.Morgan@company.com[/TD]
[TD]StacyJohns@company.com[/TD]
[TD]BrendaCobb@company.com[/TD]
[TD]Jason.Anders@company.com[/TD]
[TD]Robert.Morgan@company.com[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Brenda.Freeman@company.com; Karen.Hazen@company.com[/TD]
[TD]Brenda.Freeman@company.com[/TD]
[TD]Karen.Hazen@company.com[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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

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 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,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

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