countif formula

Dennisr53

New Member
Joined
May 29, 2015
Messages
38
I have created this countif statement but keep getting an error message when I try to apply it:

=countif(jan!C2+feb!C2+mar!C2+apr!C2+may!C2+jun!C2+jul!C2+aug!C2,"D")

It is supposed to count the total number of D's.... In this case there is a D in each cell on each worksheet so I should have a total answer of 8.

At least that is what I expected to happen instead I get an error message stating "The formula you typed contains an error."

Please help. Thanks, Dennis
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Maybe...

=SUMPRODUCT(COUNTIF(INDIRECT({"jan";"feb";"mar";"apr";"may";"jun";"jul";"aug"}&"!C2"),"D"))

Hope this helps

M.
 
Upvote 0
Thank you Marcelo. This worked perfectly. I still need to change the C2 every time I copy and paste the formula but I can work with that if necessary.

I am trying to count the same thing for multiple cell locations. So if I drag and drop the formula it all stays the same and I have to edit the cell location every time.

Thanks again,
Dennis
 
Upvote 0
Try

=SUMPRODUCT(COUNTIF(INDIRECT({"jan";"feb";"mar";"apr";"may";"jun";"jul";"aug"}&"!"&CELL("Address",C2)),"D"))

Now the C2 will incriment as the formula is dragged, and you can apply $absolute rules to the C2 as with any other formula.
 
Upvote 0
You're welcome.

Credit to Marcelo though, he did the heavy lifting. I just put in a nail.
 
Upvote 0
You can also create a named range that contains the sheet names, say SheetList, and using the improvement suggested by Jonmo, try

=SUMPRODUCT(COUNTIF(INDIRECT(SheetList&"!"&CELL("Address",C2)),"D"))

M.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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