Solved

Tweaking a concatenated formula in Excel

Posted on 2014-10-14
4
66 Views
Last Modified: 2014-10-14
I am using a simple formula in Column I to concatenate the values in Columns B, F, G & H and insert hyphens in between each string being concatenated. Sometimes there no values in Columns G & H, so the concatenated result ends up with a hyphen dangling at the end. Other times there are no values in B, F, G & H, in which case the concatenated results contains hyphens only. I would like to revise the formula to eliminate the dangling hyphen, and if there are no values, then have the cell remain blank.

I've attached a sample spreadsheet illustrating the existing formula + desired results.

Thanks!
Andrea
Sample-Concatenation.xlsm
0
Comment
Question by:Andreamary
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40380061
This formula (using the ampersand instead of CONCATENATE) should meet your requirements:
=B2&IF(F2<>"","-"&F2,"")&IF(G2&H2<>"","-"&G2&H2,"")

Regards,
-Glenn
0
 

Author Closing Comment

by:Andreamary
ID: 40380123
Perfect...thanks very much, Glenn!
Andrea
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40380131
You're welcome very much, Andrea. :-)
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40380169
Glenn,  

glad to see you back :-)
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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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 …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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…

948 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