Solved

Excel Concatenating Addresses Without Showing Blank Fields

Posted on 2011-02-15
11
449 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now