jmarkus
Mechanical
- Jul 11, 2001
- 377
I have 5 cells (but it could be more) which may or may not have a string in them.
I want to generate a string from them that looks like:
"cell1_cell2_cell3_cell4_cell5", but if cell2 is empty then it should be "cell1_cell3_cell4_cell5", if cell4 and cell5 are empty it should be "cell1_cell2_cell3" and so on.
I tried this:
=IF($C$10<>"",IF($D$10<>"",$C$10&$E$7,$C$10),""))
&(IF($D$10<>"",IF($E$10<>"",$D$10&$E$7,$D$10),""))
&(IF($E$10<>"",IF($F$10<>"",$E$10&$E$7,$E$10),""))
&(IF($F$10<>"",IF($G$10<>"",$F$10&$E$7,$F$10),""))
&(IF($G$10<>"",$G$10,""))
($c$10 is cell1, etc)
but then realized if cell2 through 4 are empty this won't work, and I would have to nest a whole bunch more if statements. Is there a better way to do this?
Thanks,
Jeff
I want to generate a string from them that looks like:
"cell1_cell2_cell3_cell4_cell5", but if cell2 is empty then it should be "cell1_cell3_cell4_cell5", if cell4 and cell5 are empty it should be "cell1_cell2_cell3" and so on.
I tried this:
=IF($C$10<>"",IF($D$10<>"",$C$10&$E$7,$C$10),""))
&(IF($D$10<>"",IF($E$10<>"",$D$10&$E$7,$D$10),""))
&(IF($E$10<>"",IF($F$10<>"",$E$10&$E$7,$E$10),""))
&(IF($F$10<>"",IF($G$10<>"",$F$10&$E$7,$F$10),""))
&(IF($G$10<>"",$G$10,""))
($c$10 is cell1, etc)
but then realized if cell2 through 4 are empty this won't work, and I would have to nest a whole bunch more if statements. Is there a better way to do this?
Thanks,
Jeff