If the first 21 characters of a cell have specific text, then take everything to the right of that....

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I have a cell where if the first 21 characters of the cell contain the text "###eWindow Add-on to " then I would like to take everything to the right of the last space in that phrase.

So if cell A1 had "###eWindow Add-on to Market Insight - Agriculture Package" then cell B1 would return "Market Insight - Agriculture Package"

If cell A2 has "###eWindow Add-on to Market Insight - Oil Package" then cell B2 would return "Market Insight - Oil Package"

Has anyone done this before, please?


###eWindow Add-on to Market Insight - Agriculture Package
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Possibly,
=IFERROR(TRIM(MID(A1,FIND("###eWindow Add-on to ",A1)*LEN("###eWindow Add-on to "),999)),"")
 
Upvote 0
Hi Dave

There's an entry with a slight variation.

So instead of

"###eWindow Add-on to Market Insight - Agriculture Package" it is

"eWindow Add-on to Market Insight Agriculture Package - CSM License" (without the three #'s at the beginning and with the characters "- CSM License" at the end.

Do you know if there's a formula that can strip out the "eWindow Add-on to " at the beginning in the "eWindow Add-on to Market Insight Agriculture Package - CSM License" example but also strip out the " - CSM License" at the end, please?
 
Upvote 0
Upvote 0
Hi Peter

I've got a couple of quick questions, please?

1) What's the reason you added 17 on the end of the formula?

2) I'm trying to add those two conditions to an existing formula, but keep on getting a 'too few arguments' error.

The formula refers to row cell B3283 in the actual file, where the discrepancy first arose. I imagine that it must be a missing bracket somewhere?

If you're able to spot it please let me know.


=IFERROR(IF(OR(LEFT(b3283,21)="###eWindow Add-on to ",LEFT(b3283,18)="eWindow Add-on to "),REPLACE(LEFT(b3283,SEARCH(" - CSM License",b3283&" - CSM License")-1),1, SEARCH("eWindow Add-on to",b3283)+17)),TRIM(LEFT(B3823,FIND("(",B3823,1)-1)),"")
 
Upvote 0
By the way, this "IF(OR" formula works.

ie if
A1 = "###eWindow Add-on to Market Insight - Agriculture Package"
A2 = "###eWindow Add-on to Market Insight - Oil Package"
A3 = "eWindow Add-on to Market Insight Agriculture Package - CSM License"

the formula below returns the correct results.

=IF(OR(LEFT(A1,21)="###eWindow Add-on to ",LEFT(A1,18)="eWindow Add-on to "),REPLACE(LEFT(A1,SEARCH(" - CSM License",A1&" - CSM License")-1),1, SEARCH("eWindow Add-on to",A1)+17,""))


However, if I replace with double quotes at the end of the formula ie "" with

TRIM(LEFT(A1,FIND("(",A1)-1))

I get a VALUE error.

But I'm not sure why? Any thoughts would be greatly appreciated, as the TRIM(LEFT(B3823,FIND("(",B3823,1)-1)) is there to account for all the other instances.

Then I'll add the IF(ERROR last to return a blank, if there is an error....
 
Upvote 0
I managed to find a way around it using =IF(ISNUMBER(SEARCH

The trim function I wanted to add on at the end would only apply IF there was a bracket or parentheses in the text.

So I used =IF(ISNUMBER(SEARCH at the beginning to search for a bracket, then put the trim function after that, then put the other two conditions above, which you kindly helped me with.

So the combined formula looks like this:

=IF(ISNUMBER(SEARCH("(",A1)),TRIM(LEFT(A1,FIND("(",A1,1)-1)),IF(ISNUMBER(SEARCH("eWindow",A1)),REPLACE(LEFT(A1,SEARCH(" - CSM License",A1&" - CSM License")-1),1, SEARCH("eWindow Add-on to",A1)+17,"")))

Thank you both for your help.
 
Upvote 0
It would still be good to understand why the number 17 was used at the end, however.

Thank you in advance.
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,892
Members
449,058
Latest member
Guy Boot

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