Amend my Formula to ignore a possible space

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have this formula:

=IF(ISERROR(SEARCH("16Cap",LOOKUP("zzzzzzz",C4))),"No","16Cap")

It works perfectly if the text in cell C4 reads 16Cap but if there is a space like this 16 Cap then it returns No.

Can my formula be altered so it can find both scenarios?

Thanks

Dan
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
=IF(ISERROR(SEARCH("16*Cap",LOOKUP("zzzzzzz",C4))),"No","16Cap")
Add the wildcard *
not sure i understand the formula , BUT using * will work for "16 Cap" or "16cap"
BUT also 16 123456789 cap or 16 [anything] cap
so maynot do what you want, as just not ignoring a space
 
Last edited:
Upvote 0
Solution
you are welcome , but as i said - its not just ignoring a space
 
Upvote 0
Hi,

I don't see the purpose of the LOOKUP in the formula, we're Not searching a Range of Cells, we're only searching in 1 cell, C4
This will Search for "Cap16" or "Cap 16" (with a space):

Book3.xlsx
CD
4abc 16 Cap xyz16Cap
Sheet886
Cell Formulas
RangeFormula
D4D4=IF(OR(ISNUMBER(SEARCH({"16Cap","16 Cap"},C4))),"16Cap","No")
 
Upvote 0
Hi jtakw,

etaf said the same thing yesterday and supplied me with this formula before editing his/her thread.

=IF(ISERROR(SEARCH("16*Cap",C4)),"No","16Cap")

Your formula works as well jtakw so thank you.

thanks

Dan
 
Upvote 0
Your formula works as well jtakw so thank you.
jtakw formula is much better as it is only looking for 2 possible entries {"16Cap","16 Cap"}
Whereas I'm using a wildcard - which will also see as true anything between 16 and CAP
so "16 AND CAP" = would be true as would anything between the 16 and the word cap
So you may get false readings from my formula. If it just happens to have other text or more spaces within 16, cap
 
Upvote 0
You're welcome danbates, and thanks @etaf

If we really want to isolate the Search strings, add a space fore and aft:

Book3.xlsx
CD
4abc 16 Cap xyz16Cap
516 Cap abc16Cap
6xyz 16 CaptainNo
7xyz 16 to 17 CapNo
8xyz 16 Cap16Cap
Sheet885
Cell Formulas
RangeFormula
D4:D8D4=IF(OR(ISNUMBER(SEARCH({" 16Cap "," 16 Cap "}," "&C4&" "))),"16Cap","No")
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,896
Members
449,194
Latest member
JayEggleton

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