Finding if a number appears in a certain cell

sunnydee003

New Member
Joined
Nov 11, 2017
Messages
9
Thank you for looking at my post. I want to know how to do the following.

If I want to know how many times the number 2 appears in a set of numbers that are in one cell.

The set of numbers in cell A2:
12 02 44 26 91 55 62

I've tried the formula:=ISNUMBER(SEARCH(SUBSTRING,TEXT)) to find it but it'll give me a TRUE for every time there is a 2 in the set of numbers, even if its the number 12.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I've tried the formula:

=ISNUMBER(SEARCH(" "&SUBSTRING&" "," "&TEXT&" "))

to find it but it'll give me a TRUE for every time there is a 2 in the set of numbers, even if its the number 12.
Try concatenating spaces (since that is the character between your numbers) on to the ends of both the text being searched for and the text being searched as shown above in red.
 
Upvote 0
Try concatenating spaces (since that is the character between your numbers) on to the ends of both the text being searched for and the text being searched as shown above in red.

That works but then I run into the problem of getting a "FALSE" for the number 2 I'm looking for because in the cell, its written as 02 and my reference is just 2. How do I make it so that numbers from 1-9 have a 0 in front of them (example: 01, 02, 03...)?
 
Upvote 0
That works but then I run into the problem of getting a "FALSE" for the number 2 I'm looking for because in the cell, its written as 02 and my reference is just 2. How do I make it so that numbers from 1-9 have a 0 in front of them (example: 01, 02, 03...)?
Are the numbers in the cells (the ones separated by spaces) always two digits long?
 
Upvote 0
Hi,

In your OP, you said "how many times the number....", so I assume there may be 0, 1, 2 or more times the search value may appear within the Text string.
Assuming the substrings are Always 2 digits, you can do one of these:


Book1
ABCDEFGHI
102 12 02 44 26 91 02 55 62 02440242099
202 12 44 26 91 55 621110
312 02 44 26 91 55 621110
412 44 26 91 55 62 990001
512 44 26 91 55 62 021110
612 02 44 26 91 02 55 622220
702 12 44 26 91 55 62 022220
Sheet154
Cell Formulas
RangeFormula
C1=(LEN(A1)-LEN(TRIM(SUBSTITUTE(A1,"02",""))))/3
D1=(LEN(A1)-LEN(TRIM(SUBSTITUTE(A1,E$1,""))))/3
F1=(LEN(A1)-LEN(TRIM(SUBSTITUTE(A1,IF(LEN(G$1)=1,0,"")&G$1,""))))/3


C1 formula has the search value "hard-coded" in the formula.
D1 formula uses a cell reference (i.e. E1), so you can change it at will (please note E1 must have 2 digits - entered as text due to leading 0)
F1 and H1 (Columns H and I are for illustration purposes only) formula is the same, uses a cell reference (i.e. G1) where you can enter either a single or double digit number for the search.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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