Microsoft Excel - how to subtotal columns from another sheet matched to the values in validation list

Asked By Ewa P on 14-Nov-12 07:14 AM
on sheet  Other Achievement I've got 2 validation lists: one of them is to select for example gender, ethnicity .... another one to select accordingly: F/M or different ethnicity.
now I want to use sumproduct  to count the number of students on sheet grades with criteria from validation list matched to table on sheet SelLIST

(for example: if data validation list is selected to gender and to F use sheet grades, column D, values F ,
but if data validation is selected to Ethnicity and to Any other white background as ethnicity use column grades!E =Any other white background .)

sorry, I can not upload any files (tried IE and Chrome), below are pics:
 Thank you in advance for help and suggestions

sheet Other Achievement 

formula in B6: when filtered on gender =F and DR:=5 it should return 95 


sheet grades:

sheet SelLIST (named range: U : A2:C10)

Harry Boughen replied to Ewa P on 14-Nov-12 10:31 PM
Hello Ewa,

Possibly the formula that you want goes something like this:


The column offsets would be determined from your lookup table rather than the range address strings that you currently have although it appears that the DR column is constant for all queries so that doesn't have to be an offset if you don't want to.

If the number of students is likely to vary with time you could also make the base range (ColumnA) dynamic so that you don't have to go changing the formulas every time the number of students changes.  This would be a good reason to leave the ColumnDR reference as an offset.

Hope this helps.  Let me know how you go.

Ewa P replied to Harry Boughen on 15-Nov-12 04:30 AM
Hello again Harry :),

I'll be trying to work with Offset today but I'll still attach the file  (attaching works today :) ) 
as i'm not very familiar with offset, trying to learn thru...
Could you have a  look please?
match column in another sheet .zip 
I also want to clear one of the validation list when the other changes, trying to learn VBA, i think i need to use OFfset here too, could you see where I'm doing something wrong wrong please?

Many thanks
Harry Boughen replied to Ewa P on 15-Nov-12 05:32 PM
Hello Ewa,

Have a look at this.  I have included some notes in the sheet.

match column in another

Ewa P replied to Harry Boughen on 16-Nov-12 05:33 AM
This is brilliant Harry! 

I'm now using this formuala for criteria in A3:4, separate for ALL, Female and Male:


and thank you for vba code, it does exactly what I needed. 


Ewa P replied to Harry Boughen on 16-Nov-12 09:00 AM
Hi, really sorry to be a pain but how can i modify the formula to sum instead of count?
Thank you again for your time and expertise


Harry Boughen replied to Ewa P on 17-Nov-12 03:59 AM
Hi Ewa,

Maybe this is what you want.


Let me know if not.

Ewa P replied to Harry Boughen on 21-Nov-12 10:30 AM
Thank you, it does exactly what I need 
Ewa P replied to Harry Boughen on 23-Nov-12 04:29 AM
Hi Harry, you'll be really fed up with me but could you advise me how to convert this formula to average cells? (same sheet)

I've got this one and it works:

but when I want to add another condition I'm getting a wrong result :
Harry Boughen replied to Ewa P on 23-Nov-12 06:32 AM
Hello Ewa,

You need a multiply (*) between your conditionals not a comma.


Ewa P replied to Harry Boughen on 26-Nov-12 04:02 AM
no, I tried multiply , it gives the wrong result,
even if I put value that is not in that column for example "d" (only f and m are possible) i get almost the same result as if I entered F or M, something
 else must be wrong 
Ewa P replied to Harry Boughen on 26-Nov-12 04:13 AM
got it! :-) I simply divided sumproduct by the number of matched students:

Harry Boughen replied to Ewa P on 26-Nov-12 04:57 AM
Hello Ewa,

Yes, sorry about leading you astray.  I have to admit that I only took a quick look at it and it only half registered that you were no longer in SUMPRODUCT mode.  Good to see that you worked it out.