Concatenate with line breaks

jongooligan

Board Regular
Joined
Jul 23, 2007
Messages
90
I've inherited a workbook with data like:

A1 = 1 The Street B1 = Anytown

In C1 if I use A1&" "&B1 I get 1 The Street Anytown

What I need in C1 is:

1 The Street
Anytown

Other info - The example shows just two of seven address lines that need to be concatenated into one cell. There are approximately 200 addresses to be manipulated.

Thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi
Paste the following codes in the macro window ( Alt F11)

Code:
Sub sss()
x = Worksheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For a = 1 To x
For b = 1 To 7
Cells(a, 8) = Cells(a, 8) & Cells(a, b) & Chr(10)
Next b
Next a
End Sub
run the macro
 
Upvote 0
=a1&" "&char(10)&b1

format cells to wrap text (on the alignment tab)
=A1&CHAR(10)&B1 should do the same job?
 
Upvote 0
yep - formally, the extra space is entirely gratuitous. functionally, though, resultant strings are easier to read (imo) when, for whatever reason, wrap text format hasn't been set, & has no adverse effects when it has.
 
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,416
Members
448,960
Latest member
AKSMITH

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