Search cell for string plus space

Okoth

Board Regular
Joined
Sep 10, 2009
Messages
106
Office Version
  1. 2019
Platform
  1. Windows
I want to check if the value of a cell is written as 100 gram (or a different number) instead of 100gr.

Example:
100gr white sugar is wrong
100 gram white sugar is right

or

38gr cinnamon is wrong
38 gram cinnamon is right

I have tried several formulas but I'm always stuck with the space.

=SEARCH("gr *", C18 ) doesn't work
=COUNTIF(C18,"*gr *")>0 also doesn't work
=ISNUMBER(SEARCH("gr *",B18)) also not

What formula can I use to check this?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Remove the *
=ISNUMBER(SEARCH("gr ",A2))
 
Upvote 0
Remove the *
=ISNUMBER(SEARCH("gr ",A2))

Sorry, but I have tried this before and again and it gives a FALSE.

Another example of what I don't want is

100 gr white sugar (is wrong)
100 gram white sugar (is right)
 
Last edited:
Upvote 0
It looks like this works

Code:
=SEARCH("gr"&CHAR(160),A2)
 
Upvote 0
It looks like this works

Code:
=SEARCH("gr"&CHAR(160),A2)
Just so you know... CHAR(160) is not a "normal" space, rather, it is a "non-breaking" space mostly used on websites to keep two words with a space between them together so they do not get split onto two different lines. You have to be careful of these when you copy text from a webpage.
 
Upvote 0
Just so you know... CHAR(160) is not a "normal" space, rather, it is a "non-breaking" space mostly used on websites to keep two words with a space between them together so they do not get split onto two different lines. You have to be careful of these when you copy text from a webpage.

Thanks for the info, Rick
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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