Concatenate,IF

C

CS

I have a worksheet that currently has 2
columns:AssemblyComments and GenComments. I want to
concatenate the 2 and prefix with label but only if there
is data in that column.
ex: AssemblyComments=Small nick on bottom and
Comments=Color Variation. I want it concatenated
as "Assembly:Small nick on bottom,Gen:Color variation".
I'm not sure how to incorporate the IF statement. Thanks
for the help.
 
D

Dave R.

You say only if there's data in that column, but you are talking about two
columns, right?

If you're talking about ensuring there's data in each column (A and B here),
try;

=IF(AND(A1<>"",B1<>""),A1&","&B1,"")

if it's just one column you want to check,

=IF(A1<>"",A1&","&B1,"")
 
G

Guest

Almost there. I tried adding the prefix to indicate where
the data came from:
=IF(AND G50<>"",S50<>""),
"Assembly:"&G50&","&"GenComments:"&S50,"")
But if I have comments in G50 but not in S50 I get:
Assembly:Testing,GenComments:
and if I have comments in S50 but not in G50 I get nothing.
 
D

Dave R.

"AND G50" is not right- AND is a function and works on things within
parentheses;

=IF(AND(G50<>"",S50<>""),"Assembly:"&G50&","&"GenComments:"&S50,"")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top