Solved

Remove comma if no data found

Posted on 2016-08-04
4
39 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
[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 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 52

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

729 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