Solved

Excel Concatenating Addresses Without Showing Blank Fields

Posted on 2011-02-15
11
461 Views
Last Modified: 2012-05-11
I have an exported Excel file with the address in 3 different columns and want to combine them into one column.  Looked up merge cells and tried it but it wasn't helpful.  Tried writing a concatenation formula and adding commas between say the address and suite number, which worked; however, I don't want to include a comma and space when the suite field is empty.  Any suggestions?
0
Comment
Question by:rvfowler2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 34898521
Can any (all) of the three columns be blank?
0
 
LVL 16

Assisted Solution

by:sjklein42
sjklein42 earned 50 total points
ID: 34898541
Make the commas conditional by using the IF function, something like this:
CONCATENATE(cell1, IF( cell1 = '', '', ',' ), cell2, IF( cell2 = '', '', ',' ), cell3 )

Open in new window

0
 
LVL 22

Assisted Solution

by:rspahitz
rspahitz earned 50 total points
ID: 34898544
What formula do you have now?
What is in the 3 cells?
Where does the suite number come from?

Typically, you'd do something like this (or the corresponding CONCATENATE command):

=A1 & ", " & A2 & ", " & A3

However, to skip A2 if blank, use something like this:

=A1 & ", " & IF(A2="", "", A2 & ", ") & A3

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

by:StephenJR
ID: 34898578
This maybe?

=TRIM(CONCATENATE(A2,IF(A2<>"",", ",""),B2,IF(B2<>"",", ",""),IF(C2<>"",C2, "")))
0
 
LVL 24

Assisted Solution

by:StephenJR
StephenJR earned 100 total points
ID: 34898620
Small change:

=TRIM(CONCATENATE(IF(A2<>"",A2&", ",""),IF(B2<>"",B2&", ",""),IF(C2<>"",C2, "")))
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 300 total points
ID: 34899492
..but that would still give you a trailing comma if, say, A2 and B2 only are populated.

Try this to avoid that

=SUBSTITUTE(IF(A2="","",", "&A2)&IF(B2="","",", "&B2)&IF(C2="","",", "&C2),", ","",1)

regards, barry
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 34899908
Oops, missed that. Nice work Barry.
0
 
LVL 2

Author Comment

by:rvfowler2
ID: 34901431
OK, an IF statement just like Filemaker.  This is close, but you need to account for a blank first cell as well.  Attaching file that gives all possible combos and will give credit to somone if they get it before me (though will give partial to all if you don't since you pointed me in the right direction).
-AddressConcat.xls
0
 
LVL 2

Author Comment

by:rvfowler2
ID: 34901473
Figured it out.  The only change was in the first part of the calc, to put the comma (but in this case it would be a period) AFTER the cell (A2) as follows:

=SUBSTITUTE(IF(A2="","",A2&", ")&IF(B2="","",", "&B2)&IF(C2="","",", "&C2),", ","",1)

Awarding points.
0
 
LVL 2

Author Closing Comment

by:rvfowler2
ID: 34901501
Thanks.  Hope my points are fair.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 34901533
Seems that you got several good solutions and picked the best one for your needs.  Works for me :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question