Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show Contents of Cell A1 & B1 in Cell D1 + conditional show C1

Status
Not open for further replies.

Kenny2003

Technical User
Dec 29, 2002
53
GB
Hi Gang,

I have a litle problem thats been bugging me and I cant seem to get right so I wondered if anyone can offer a solution, Here's what I need to do.

I need to show the contents of Cell A1 & B1 in cell D1 (seperated by a "-" symbol) but also show the contents of Cell C1 if it has data in it but ignore it if its empty. For Example:

A1 B1 C1 D1
Text1 Text2 Text3 Text1 - Text2 Text3
Text1 Text2 Text1 - Text2

So far I have the following formula:
=A1 & "-" & B1 & " " & G1413

But its the conditional part I can not do - the part thats "if empty then ignore" but if has text then include it.

Can anyone help me with this

Thank you in advance


Kenny
 
Kenny,
[tt]
=A1&"-"&B1&If(ISBLANK(C1),"",C1)
[/tt]


Skip,
[sub]
[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue][/sub]
 
Hi Kenny,

I don't understand.

[blue][tt] =A1 & "-" & B1 & C1[/tt][/blue]

will append C1 and if there is nothing in C1 it will append that nothing. Skip's formula will also do that but has the flexibility for you to include something else as well if and only if C1 has data - is that what you want? And what has G1413 got to do with it?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Hi Guys,

Thank you both for replying to my post - I really appreciate it.

First to Tony: G1413 was a typo error, It should not have appeared in my post - sorry for the confuson.

Skip: Thanks for that solution, it works a treat. No matter how hard I try I can never write these formula's and I do try hard before posting in here.

Thank you both again,

Kind Regards,


Kenny
 
The formulae posted by Skip & Tony don't quite do what was asked for. Both omit the space between B1 & C1.

In Skip's case, change the formula to:
=A1&"-"&B1&If(ISBLANK(C1),""," "&C1)

Another, providing your source cells never have leading/trailing spaces or embedded double-spaces of their own, way is:
=TRIM(A1&"-"&B1&" "&G1)
But then again, you might prefer the surplus spaces to be cleaned up this way.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top