Search for multiple text strings and return abbreviations if present

mordecai98

New Member
Joined
Jan 17, 2018
Messages
4
In column B, the following options are available:
<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th
In column C, if Session 1 is resent, I'd like to display 1. If Session 1 and Session 2 are present, I'd like to display 1,2, etc.

I can do this for just Session 1, but not sure how to do this with all 4 sessions.

Thanks
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,350
In column B, the following options are available:
Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th

Is this in one cell or several cells in column B? You haven't specified.

How many sessions can there be as a maximum?
 
Last edited:

mordecai98

New Member
Joined
Jan 17, 2018
Messages
4
<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th
Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th
Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th
Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th

<colgroup><col width="237"></colgroup><tbody>
</tbody>
This is how they look. The cell to the right should show 1,2,3,4 or 3,4.
 

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,350

ADVERTISEMENT

Will this do?
(Not comma separated)

=TRIM(IF(ISNUMBER(SEARCH("Session 1",A1)),"1 ","")&IF(ISNUMBER(SEARCH("Session 2",A1)),"2 ","")&IF(ISNUMBER(SEARCH("Session 3",A1)),"3 ","")&IF(ISNUMBER(SEARCH("Session 4",A1)),"4 ",""))
 

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,465
Office Version
  1. 365
Platform
  1. Windows
This should all be in one cell.
There can be 4 sessions Max.

Hi, welcome to the forum!

Here is just another option that you can try.

<b>Excel 2013/2016</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th</td><td style="text-align: right;background-color: #FFFF00;;">1,2,3,4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th</td><td style="text-align: right;;">1,2,3,4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">Session 1: Sunday July 1st – Friday July 6th, Session 2: Sunday July 8th – Friday July 13th, Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th</td><td style="text-align: right;;">1,2,3,4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">Session 3: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th</td><td style="text-align: right;;">3,4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">Session 1: Sunday July 15th – Friday July 20th, Session 4: Sunday July 22nd– Friday July 27th</td><td style="text-align: right;;">1,4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style=";">Session 4: Sunday July 15th – Friday July 20th</td><td style="text-align: right;;">4</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">B1</th><td style="text-align:left">=SUBSTITUTE(<font color="Blue">TRIM(<font color="Red">SUBSTITUTE(<font color="Green">SUMPRODUCT(<font color="Purple">0+ISNUMBER(<font color="Teal">SEARCH(<font color="#FF00FF">"Session "&{1,2,3,4}&":",A1</font>)</font>),{1000000,20000,300,4}</font>),0," "</font>)</font>)," ",","</font>)</td></tr></tbody></table></td></tr></table><br />
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,805
Messages
5,598,173
Members
414,217
Latest member
Mystix

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
Top