Formatting Addresses using line breaks

NewNoise

New Member
Joined
Jan 23, 2012
Messages
2
I have a spreadsheet with address information, with columns for Address Line 1, Address Line 2, City, State, and ZIP. I'd like to combine each of the columns into a single, formatted column, with line breaks in the address as follows:

Address Line 1 (break)
Address Line 2 (break)
City, State ZIP-ZIP2

(Some cases don't have ZIP2--it's those additional 4 numbers at the end of some ZIP codes)

This is the code I came up with:

=AH2&CHAR(10)&AI2&CHAR(10)&AJ2&", "&AK2&" "&AL2&IF(AM2="","","-"&AM2)

The code works wonderfully for cases that have data in each of those cells. It does not work so wonderfully for those that have nothing in Address Line 2; the result is simply a blank line in the address.

What I'd like to do, then, is have conditional line breaks. I can't figure out how to get it to work, though. Here's the conditional code I came up with (that isn't working):

=AH6&IF(AI6="","",CHAR(10)&AI6)&CHAR(10)&AJ6&", "&AK6&" "&AL6&IF(AM6="","","-"&AM6)

The above code works great for cases that have nothing in Address Line 2, but for cases that do, it simply cuts those addresses off after Address Line 2.

Any help you could provide would be greatly appreciated.
 

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