COUNTIF values on another sheet based on specific value

jmacl

New Member
Joined
Apr 13, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi I am working on a vacation tracker and need find the name of an employee in a table then count the number of times "H" is in the row of the name.
Basically i need to find the row for a work on another sheet then count the number of holidays they have taken, this will then be expanded to sick days and other absence based on a character reference in the table.
I am have tired the following but get an error:
Excel Formula:
=COUNTIF(INDIRECT(&"'Jan2021'!"&MATCH(A10,'Jan2021'!A9:A44,0)&":'Jan2021'!"&MATCH(A10,'Jan2021'!A9:A44,0)&"),"H")
I will then replicate this across multiple sheets
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I am not sure that I am understanding what you are trying to achieve.
You seem to be looking in the same column (A) for both the name (which I assume is in A10) and for H.

If the Name on the Jan2021 sheet is in A9:A44
and the value "H" is on the Jan2021 sheet is in B9:B44\
Then your formula would look something like this.
Excel Formula:
=COUNTIFS(INDIRECT("'Jan2021'!" & "$A$9:$A$44"),A10,INDIRECT("'Jan2021'!" & "$B$9:$B$44"),"H")

However hardcoding Jan2021 would make the Indirect function an unnecessary complication, so I would assume it will be driven by a cell.
So if you put the Jan2021 as a string value in B1 then you would need:-
Excel Formula:
=COUNTIFS(INDIRECT("'"&$B$1&"'!" & "$A$9:$A$44"),A10,INDIRECT("'"&$B$1&"'!" &"$B$9:$B$44"),"H")

If you are going to put the Jan 2021 into B1 as a date, you would need this:-
Excel Formula:
=COUNTIFS(INDIRECT("'"&TEXT($B$1,"mmmyyyy")&"'!" & "$A$9:$A$44"),A10,INDIRECT("'"&TEXT($B$1,"mmmyyyy")&"'!" &"$B$9:$B$44"),"H")
 
Upvote 0
Thank you Alex for your reply but I don't think we are there yet, you have highlighted something I was not clear on, the "H" values will be in columns B through until AF.
So to reconfirm, I need to find a row in column A based on a specific value (name) then count the number of "H" in that row in columns B through to AF.
 
Upvote 0
I don't know why you are using INDIRECT. Is there a list of sheet names somewhere?

To get the count in the sheet named Jan2021 try
=COUNTIF(INDEX('Jan2021'!$B$9:$AF$44,MATCH(A10,'Jan2021'!$A$9:$A$44,0),0),"H")

M.
 
Upvote 0
Solution
I don't know why you are using INDIRECT. Is there a list of sheet names somewhere?

To get the count in the sheet named Jan2021 try
=COUNTIF(INDEX('Jan2021'!$B$9:$AF$44,MATCH(A10,'Jan2021'!$A$9:$A$44,0),0),"H")

M.
Hi Marcelo, this is great!, I have a list starting AR3:AR14 what do you have in mind
 
Upvote 0
You could put this in AS3 and copy it down.
Excel Formula:
=IFERROR(COUNTIFS(INDEX(INDIRECT("'"&TEXT($AR3,"mmmyyyy")&"'!" & "$B$9:$AF$44"),MATCH($A$10,INDIRECT("'"&TEXT($AR3,"mmmyyyy")&"'!" &"$A$9:$A$44"),0),0),"H"),"")

20210413 Countifs with Indirect.xlsx
ARAS
1
2
3Jan-215
4Feb-21 
5Mar-21 
6Apr-21 
7May-21 
8Jun-21 
9Jul-21 
10Aug-21 
11Sep-21 
12Oct-21 
13Nov-21 
14Dec-21 
15
Lookup
Cell Formulas
RangeFormula
AS3:AS14AS3=IFERROR(COUNTIFS(INDEX(INDIRECT("'"&TEXT($AR3,"mmmyyyy")&"'!" & "$B$9:$AF$44"),MATCH($A$10,INDIRECT("'"&TEXT($AR3,"mmmyyyy")&"'!" &"$A$9:$A$44"),0),0),"H"),"")
 
Upvote 0
Hi Marcelo, this is great!, I have a list starting AR3:AR14 what do you have in mind

Something like

Pasta1
ARAS
1
2
3Jan20216
4Feb2021 
5Mar2021 
6Apr2021 
7May2021 
8Jun2021 
9Jul2021 
10Aug2021 
11Sep2021 
12Oct2021 
13Nov2021 
14Dec2021 
Plan1
Cell Formulas
RangeFormula
AS3:AS14AS3=IFERROR(COUNTIF(INDEX(INDIRECT(AR3&"!$B$9:$AF$44"),MATCH(A$10,INDIRECT(AR3&"!$A$9:$A$44"),0),0),"H"),"")


M.
 
Upvote 0
Excellent thanks for your help on this, I have everything i need on this.
 
Upvote 0

Forum statistics

Threads
1,215,572
Messages
6,125,605
Members
449,238
Latest member
wcbyers

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