Need help creating Macro to combine text cells....Please

rsajdak

New Member
Joined
Nov 3, 2005
Messages
4
I am trying to create a Macro where I can select a few cells that has text and the Macro will combine all the text into one cell while keeping line breaks at the end of each line.

The first table shows the cells prior to executing the Macro. I want to select the cells that I want to combine and then run the Macro.

The second table shows the desired outcome (please note the line breaks).

Can anyone please help me out with a Macro?
Compliance.xls
BCDE
558SI_VOCS_4_313AH/back-up:
55910occupies
56001vacant
56111signalinvalidly
562SI_VOCS_4_312SBR:
56310occupies
56401vacant
56511signalinvalidly
Sheet1
Compliance.xls
BCDE
558SI_VOCS_4_313AH/back-up:
55910occupies 01vacant 11signalinvalidly
560
561
562SI_VOCS_4_312SBR:
56310occupies 01vacant 11signalinvalidly
564
565
Sheet1
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi

Try
Code:
Sub aaa()
 For Each ce In Selection
  holder = holder & ce & vbLf
 Next ce
 
 Selection.ClearContents
 ActiveCell.Value = Left(holder, Len(holder) - 1)

End Sub


Tony
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

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