简体   繁体   中英

Excel Formula to count rows in a column when a criteria is met in another column

I have two sheets "Aug" & "Dashboard." The "Aug" sheet it is always growing and it has multiple columns, but the important ones are "Week" (Week is in B3) and "Group" (in C3).

I am able to do a formula that will count if any row in the "Group" column has the word "Harvest". =COUNTIF(Aug!C3:Aug!C1301,"Harvest")

But, I would also like to be able to count the number of times Harvest shows up depending on the week and to put that information in a certain cell in the "Dashboard" Sheet.

Here is what the "Aug" sheet could look like

Week Group 
31   harvest
31   harvest
31   rqst
31   harvest
32   harvest
32   harvest

The "Dashboard" sheet has a cell (A35) where you type in the week you want to look at. For example if I want the sheet to count how many times the word harvest shows up in week 31 then I would type 31 and I should expect the number 3 to turn up.

I tried using a countif formula and an if formula, but that didn't work for me. Here is the formula that I tried using.

=IF(Dashboard!A36=Aug!B4:AugB1301, COUNTIF(Aug!C4:Aug!C1302,"Harvest"))

I get a #name! error.

I then tried focusing on just one cell to see but I can't even get that to pull correctly.

=IF(Dashboard!A36=Aug!B1302, COUNTIF(Aug!C4:Aug!C1302,"Harvest"))

So What I understand from my formula is that If the number in cell A35 matches a the cell in the Aug sheet b1302, the it should count the entire column C and count how many times the word harvest comes up. I keep getting a False statement.

I can make the countif statement work on it's own. I can use the count if statement to give me a total of "harvest" in the entire column.

I want it to count per the week i tell it to.

Snippet of my Dashboard sheet

Example of my Aug Sheet where I want to focus on just one cell

And, if there is a VBA code that does this then it will be so much better because I will be able to have the formulas hidden.

Thank you

带有S COUNTIFS()允许多个条件:

=COUNTIFS(Aug!C3:Aug!C1301,"Harvest",Aug!B3:Aug!B1301,Dashboard!A36)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM