Need to COUNTIF several numbers exist in a column of data

Jennifre

Board Regular
Joined
Jan 11, 2011
Messages
160
I have a column of data (A) like this:
1111
1231
1333
1112
1121
1122
1311
1333

And I have sets of these numbers which need to be COUNTIF'd they match each of the sets, for example:
1111, 1112
1221, 1321, 2432
3131, 2323

I need to get the total from column A of each set of the longer numbers. I tried using a COUNTIF like this
=COUNTIF(A$2:A$127,1111)
BUT, when I add the comma to add the next set, Excel is converting the number into 11,111,112 rather than allowing the COUNTIF function to COUNTIF both of those (1111, 1112) exist in column A. And the function breaks by adding the other numbers separated by a comma. So I need to know how to tell this formula to look for the SET of these numbers in column A.

How can I do this? Thanks SO much for your help!! :)
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You need to put the two values to be matched in an array, then sum the results.
Try this regular formula:
=SUM(COUNTIF(A$2:A$127,{1111,1112}))

Does that help?
 
Upvote 0
Hi, thank you. That didn't seem to work though. I got "0" as a result, and the real count is something maybe like 45. True true, I could likely do this [at this point] faster just counting, but I want to understand the syntax of the formula's language. I wonder what else I could try.... Thank you though, Ron! :)
 
Upvote 0
A count of 0 indicates that there are no matches. Select one of the cells that you believe should match and check if it has any invisible leading or trailing characters. Let us know what you find.
 
Upvote 0
Hi, thank you again. Well... these numbers are a calculation determined by a loooong formula in the cells creating these numbers. I can give you an example of that formula if it helps:
=(DC127*1000)+(DD127*100)+(DE127*10)+(DF127*1)

But, no one "entered" anything into these cells but for Mr Excel Formula, so I imagine there are no invisible characters. (And, I can see the numbers I'm trying to count, so I know they're there, pesky critters!)
 
Upvote 0
Ok...try this:
• Select one of the cells you believe is a match.
• Press F2...Press F9
That will calculate the result.
(If you see something like 1111.00009237 then you'll need to use one of the rounding functions: INT, ROUND, ROUNDUP, etc.)

• Press ESC to see the formula again
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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