SumIfs Using Indirect based on 2 Criteria

MINDFULLYLIZ

New Member
Joined
Sep 2, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hi! I have been struggling for 5 days trying to get this formula to work. Basically, I need it to search across a few worksheets which I have named "JON" and sum a corresponding cell if it meets two conditions.

The formula returns a "Value" error:

=SUMIFS(INDIRECT("'"&JON&"'!$F$16:$F$65"),INDIRECT("'"&JON&"'!$A$16:$A$65"),$A5,INDIRECT("'"&JON&"'!A1:A1"),$B5))

Please tell me what I'm doing wrong.

Also note on the second criteria I've changed the "A1:A1" to just A1 and A1:A2 and A1:B2 to see if that helps
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

kweaver

Well-known Member
Joined
May 8, 2018
Messages
1,808
Office Version
  1. 365
  2. 2010
Welcome to MrExcel.

Why do you need to use INDIRECT? Your formula returns an error because JON has no value. Is that the name of the sheet?

Code:
SUMIFS(JON!$F$16:$F$65,criteria1,JON!$A$!6:$A$65,criteria2,JON!$A$1,$B5)

Is the third criteria that JON!A1 = B5 ?
It's not clear to me what the 1st and 2nd criteria are.

If you presented a sheet using XL2BB, it would help understanding your objectives.
 

MINDFULLYLIZ

New Member
Joined
Sep 2, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hi and thank you for helping. I thought I had to use the indirect function in order to reference the different worksheets?

The first criteria is JON!A1=B5
and the second is JON!A16:A65 =A5
the sum range would be JON!F16:F65
 

MINDFULLYLIZ

New Member
Joined
Sep 2, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
I entered this =SUMIFS(JON!$F$16:$F$65,JON!$A$16:$A$65,$A5,JON!$A$1,$B5)

and I get this error:
1599099815167.png
1599099815167.png
 

kweaver

Well-known Member
Joined
May 8, 2018
Messages
1,808
Office Version
  1. 365
  2. 2010

ADVERTISEMENT

I don't quite understand your logic, but try this:

Code:
=SUMPRODUCT((JON!A1=B5)*(JON!A16:A65=A5)*(JON!F16:F65))

It seems that if A1 <> B5 the sum will be 0. Is that right?

If this is all run on the JON sheet, you don't need to use the JON reference. Just:

Code:
=SUMPRODUCT((A1=B5)*(A16:A65=A5)*(F16:F65))
 

kweaver

Well-known Member
Joined
May 8, 2018
Messages
1,808
Office Version
  1. 365
  2. 2010
If you posted a sheet using XL2BB, it would help
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
57,000
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

@MINDFULLYLIZ
With SUMIFS all the criteria ranges must be the same size, which is why you formula doesn't work.
Can you post some sample data using the XL2BB add-in?

@kweaver
I think that JON is a range name which has the sheet names the formula should look at.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
57,000
Office Version
  1. 365
Platform
  1. Windows
If you have an additional range name next to the JON range that shows whether the sheet should be included, you could use
Excel Formula:
=SUMPRODUCT((Incl=B5)*(SUMIF(INDIRECT("'"&JON&"'!A16:A65"),A5,INDIRECT("'"&JON&"'!F16:F65"))))
Where Incl is the new range name.
 

MINDFULLYLIZ

New Member
Joined
Sep 2, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
If you have an additional range name next to the JON range that shows whether the sheet should be included, you could use
Excel Formula:
=SUMPRODUCT((Incl=B5)*(SUMIF(INDIRECT("'"&JON&"'!A16:A65"),A5,INDIRECT("'"&JON&"'!F16:F65"))))
Where Incl is the new range name.


Hi! I used this formula as : =SUMPRODUCT(("'"&JON&"'!$A$1"=B5)*(SUMIF(INDIRECT("'"&JON&"'!A16:A65"),A5,INDIRECT("'"&JON&"'!F16:F65"))))

It's the first formula that hasn't returned an error, resulted in "0" answer should be 100 - but I'm going to play w/this and see what it's not picking up
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
57,000
Office Version
  1. 365
Platform
  1. Windows
Try it like
Excel Formula:
=SUMPRODUCT((COUNTIF(INDIRECT("'"&JON&"'!A1"),B5))*(SUMIF(INDIRECT("'"&JON&"'!A16:A65"),A5,INDIRECT("'"&JON&"'!F16:F65"))))
 

Watch MrExcel Video

Forum statistics

Threads
1,130,381
Messages
5,641,827
Members
417,240
Latest member
pjohnsonexcel

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
Top