Another option may be to use a user-defined function. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code below into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Enter the formulas as shown in the screen shot below and copy down.
Of course you would only need one of these. Which one again comes back to what your data is like. For example the result in B3 is probably not what you want but then your data may never be like A3. However, if it could be, the second UDF (column C) would cope with that.
<font face=Courier New><SPAN style="color:#00007F">Function</SPAN> Strategy2(s <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br> <SPAN style="color:#00007F">Dim</SPAN> strt <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, stp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br> <br> <SPAN style="color:#00007F">Const</SPAN> Marker <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "Strategy2 is not "<br> <br> strt = InStr(1, s, Marker, 1)<br> <SPAN style="color:#00007F">If</SPAN> strt > 0 <SPAN style="color:#00007F">Then</SPAN><br> strt = strt + Len(Marker)<br> stp = InStrRev(s, """")<br> <SPAN style="color:#00007F">If</SPAN> stp > strt <SPAN style="color:#00007F">Then</SPAN><br> Strategy2 = Mid(s, strt, stp - strt + 1)<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN><br><br><SPAN style="color:#00007F">Function</SPAN> Strat2(s <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br> <SPAN style="color:#00007F">Static</SPAN> RegEx <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN><br><br> <SPAN style="color:#00007F">Const</SPAN> Marker <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "Strategy2 is not "<br><br> <SPAN style="color:#00007F">If</SPAN> RegEx <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN><br> <SPAN style="color:#00007F">Set</SPAN> RegEx = CreateObject("VBScript.RegExp")<br> <SPAN style="color:#00007F">With</SPAN> RegEx<br> .Pattern = Marker & "(""[A-Z]+"", )*(""[A-Z]+"")(?= )"<br> .IgnoreCase = <SPAN style="color:#00007F">True</SPAN><br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> <SPAN style="color:#00007F">If</SPAN> RegEx.test(s) <SPAN style="color:#00007F">Then</SPAN><br> Strat2 = Replace(RegEx.Execute(s)(0), Marker, "", 1, 1, 1)<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN></FONT>
Excel Workbook |
---|
|
---|
| A | B | C |
---|
1 | Detail: Region is "USD" Reinvestment Period is until first day after 1 full month and Detail: Currency is "USD" and Detail: Strategy2 is not "ABR", "MAR", "O", "PI", "ILB", "HY", "SP" Reinvestment Period is until first day of full month | "ABR", "MAR", "O", "PI", "ILB", "HY", "SP" | "ABR", "MAR", "O", "PI", "ILB", "HY", "SP" |
---|
2 | Detail: Region is "USD" Reinvestment Period is until first day after 1 full month and Detail: Currency is "USD" and Detail: Strategy3 is not "ABR", "MAR", "O", "PI", "ILB", "HY", "SP" Reinvestment Period is until first day of full month | | |
---|
3 | Detail: Region is "USD" Reinvestment Period is until first day after 1 full month and Detail: Currency is "USD" and Detail: STRATEGY2 is NOT "ABR" Other Data "ABC" | "ABR" Other Data "ABC" | "ABR" |
---|
|
---|