Concatenate data from mutiple cells only if they contain certain values

SKooLZ

New Member
Joined
Oct 7, 2014
Messages
30
Hi Gurus,

I'm new to this community/forum and I am hoping you can help me with the most easiest and efficient way (Formula or VB code) to get an excel spreadsheet to Concatenate data from mutiple cells only if those individual contain certain values as shown in the example table below. Example explained.

Concatenate all comments from A - F into column H only if the statuses = Bad or OK and ignore if the statuses = Good. These controlling values with be in text form as intimated above. Also, I would like each of the coment pairs to be listed on each row/line via &CHAR(10)&.

You urgent help is much appreciated.

Thanks in advance

Skoolz

A
B
C
D
E
F
G
H
Reason
Status
Reason
Status
Reason
Status
Total
No issues
Good
Major issues
Bad
Minor issues
OK
Bad - Major issues
OK - Minor issues
Good
Good
Good
Minor issues
OK
Good
Good
OK - Minor issues

<TBODY>
</TBODY>
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Based on your specific layout I'd probably just brute force it.

Code:
=IF(OR(B3="Bad",B3="Ok"),B3&" - "&A3&CHAR(10),"")&
IF(OR(D3="Bad",D3="Ok"),D3&" - "&C3&CHAR(10),"")&
IF(OR(F3="Bad",F3="Ok"),F3&" - "&E3,"")

edit - removed the CHAR(10) following the E3.
 
Last edited:
Upvote 0
Thanks for your speedy and helful response Asala42, however I have about 12 statuses which are about 4 words long so you can imagine how long that formula becomes, whereas I only have two status text strings that I want to instruct excel to do nothing.

Is there anyway to switch the formula round to do nothing if cells contain the text else concatenate all other statuses?

Thanks again..
 
Upvote 0
Just to report back, I have manged to switch the fomula round sucessfully to do what I wanted to thanks again Asala for you help! Kudos!!!

See below

=IF(OR(B3="Good",B3=""),"",B3&" - "&A3&CHAR(10)&IF(OR(D3="Good",D3=""),"",D3&" - "&C3&CHAR(10)&
IF(OR(F3="Good",F3=""),"",F3&" - "&E3)
</PRE>
 
Upvote 0
Hi Gurus,

I'm new to this community/forum and I am hoping you can help me with the most easiest and efficient way (Formula or VB code) to get an excel spreadsheet to Concatenate data from mutiple cells only if those individual contain certain values as shown in the example table below. Example explained.

Concatenate all comments from A - F into column H only if the statuses = Bad or OK and ignore if the statuses = Good. These controlling values with be in text form as intimated above. Also, I would like each of the coment pairs to be listed on each row/line via &CHAR(10)&.

You urgent help is much appreciated.

Thanks in advance

Skoolz

ABCDEFGH
ReasonStatusReasonStatusReasonStatusTotal
No issuesGoodMajor issuesBadMinor issuesOKBad - Major issues
OK - Minor issues
GoodGoodGood
Minor issuesOKGoodGoodOK - Minor issues

<tbody>
</tbody>

As a disclaimer I am no expert... just trying to get better at excel by trying to work other people's issues. I have this really long formula that I believe does what you would like...

=IF(OR(B56:G56 = "bad"),INDEX(B56:G56,,MATCH("bad",B56:G56,0))&"-" &INDEX(B56:G56,,MATCH("bad",B56:G56,0)-1),0) = Bad - Major Issues

In order to also encompass the "ok" you would need to basically copy that entire formula and put in "ok" in the false statement. Its a lot, and I have no doubt that there is a far more eloquent solution.
 
Upvote 0

Forum statistics

Threads
1,214,824
Messages
6,121,784
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top