Solved

Remove comma if no data found

Posted on 2016-08-04
4
31 Views
Last Modified: 2016-08-05
How do I modify the following to handle if the results only return a comma, to remove the comma.

=VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],5,FALSE) & ", " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],6,FALSE) & "  " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],7,FALSE)

results = City, ST  ZipCode
0
Comment
Question by:Karen Schaefer
4 Comments
 
LVL 7

Expert Comment

by:Phil Davidson
ID: 41743538
I would try this:

=IF(LEFT(A1,2)=",",SUBSTITUTE(A1,",",""),IF(RIGHT(A1,2)="--",SUBSTITUTE(A1,",",""), A1))

I got the idea from one of the answers here.  If a comma is the right most character and left most character, one comma will be replaced with nothing.
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 250 total points
ID: 41743552
also can try:
=TRIM( IF( VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],5,FALSE) = "" , "", VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],5,FALSE) & ", " ) & VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],6,FALSE) & "  " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],7,FALSE) )

Open in new window

0
 
LVL 4

Assisted Solution

by:Alexandre Michel
Alexandre Michel earned 250 total points
ID: 41744106
you can use this formula

IF ( X = "," , "" , X )

if X is a comma return nothing otherwise return X itself


replace X with VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],5,FALSE) & ", " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],6,FALSE) & "  " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],7,FALSE)

and it becomes

IF ( VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],5,FALSE) & ", " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],6,FALSE) & "  " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],7,FALSE) = "," , "" , VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],5,FALSE) & ", " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],6,FALSE) & "  " &VLOOKUP(MainFormTbl[Company Name],BillingInfo[#All],7,FALSE) )

Alex
0
 

Author Closing Comment

by:Karen Schaefer
ID: 41744422
thanks for the great suggestion.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

757 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

23 Experts available now in Live!

Get 1:1 Help Now