Excel Concatenating Addresses Without Showing Blank Fields

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?
LVL 2
rvfowler2Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
barry houdiniConnect With a Mentor Commented:
..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
 
StephenJRCommented:
Can any (all) of the three columns be blank?
0
 
sjklein42Connect With a Mentor Commented:
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
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
rspahitzConnect With a Mentor Commented:
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
 
StephenJRCommented:
This maybe?

=TRIM(CONCATENATE(A2,IF(A2<>"",", ",""),B2,IF(B2<>"",", ",""),IF(C2<>"",C2, "")))
0
 
StephenJRConnect With a Mentor Commented:
Small change:

=TRIM(CONCATENATE(IF(A2<>"",A2&", ",""),IF(B2<>"",B2&", ",""),IF(C2<>"",C2, "")))
0
 
StephenJRCommented:
Oops, missed that. Nice work Barry.
0
 
rvfowler2Author Commented:
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
 
rvfowler2Author Commented:
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
 
rvfowler2Author Commented:
Thanks.  Hope my points are fair.
0
 
rspahitzCommented:
Seems that you got several good solutions and picked the best one for your needs.  Works for me :)
0
All Courses

From novice to tech pro — start learning today.