Countifs and indirect dynamic ranges

BigAlzBub

New Member
Joined
Oct 22, 2008
Messages
25
Hi,

I'm having difficulty with an excel problem using countifs and dynamic ranges
here a brief example of what I'm trying to do (the real thing is way more complicated)
Name
Year
English
Maths
Student1
9
c
d
Student2
9
d
b
Student3
10
b
c
Student4
11
c
c

<tbody>
</tbody>

I've created dynamic ranges for all the columns (except name), with the following statement in the name manager.
=OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$A:$A)-1,1)
obviously changing the first reference to account for the different columns
when I use the following statement everything works fine
=countifs(year,9,english,"c")
however if I type the word english in another cell (Eg E1) and then use an indirect statement I get a #ref error
=countifs(year,9,indirect(E1),"c")

Can anyone shed any light on this for me?
Thanks in advance.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi,

As I understand it, Named Ranges which are dynamic cannot be referenced using INDIRECT.

You need to use EVALUATE as a workaround. For example, with english in E1 as you give, create a new Named Range, english2 say:

=EVALUATE(Sheet1!$E$1)

Now use this in your formula instead (though with E1 still containing english, not english2):

=COUNTIFS(year,9,english2,"c")

Regards
 
Upvote 0
Edit: english2 was not a very good choice of name! Especially since you will be using this cell as a means to reference whichever Named Range cell E1 contains. Perhaps something like Subject is a better choice.

Then =COUNTIFS(year,9,Subject,"c") will do as you require, i.e. perform the count based on whatever Named Range cell E1 contains, providing you follow my instructions as in my previous post.

Regards
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

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