Average cells based on a date criteria, with blanks cells in various rows...

mad3

Board Regular
Joined
Sep 15, 2009
Messages
128
Office Version
  1. 365
Platform
  1. Windows
I want to average the cells in third column (c) based on the dates in first column (A) being less than the date in the top left cell (A1). However, since there is a blank cell within the range, I am getting a divide by zero error. How do I get around this?


column A column B column C
3/23/2024
Boston
DateTeamPCT
2/12/24New York (A).381
2/17/24Toronto.556
1 Day Off
2/21/24Baltimore.619
3/3/24San Francisco.333
3/14/24Cleveland.286
1 Day Off
3/23/24Texas.667
3/24/24Arizona.476
3/31/24Kansas City.429
4/7/24New York (N).571
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about this?

Book4
ABCDE
13/23/24
2Boston
3DateTeamPCTResult
42/12/24New York (A)0.3810.435
52/17/24Toronto0.556
61 Day Off
72/21/24Baltimore0.619
83/3/24San Francisco0.333
93/14/24Cleveland0.286
101 Day Off
113/23/24Texas0.667
123/24/24Arizona0.476
133/31/24Kansas City0.429
144/7/24New York (N)0.571
Sheet1
Cell Formulas
RangeFormula
E4E4=AVERAGEIFS(C4:C14, A4:A14, "<" & A1, C4:C14, "<>")
 
Upvote 0
Solution
However, since there is a blank cell within the range, I am getting a divide by zero error. How do I get around this?
What formula were you using?
Do you actually need the extra condition in the AVERAGEIFS formula? Do you have circumstances where the shorter formula below would not work?
If so, could we have some sample data with XL2BB?

24 03 24.xlsm
ABCDEF
123/03/2024
2Boston
3DateTeamPCTResult
412/02/2024New York (A)0.3810.472250.47225
517/02/2024Toronto0.556
61 Day Off
721/02/2024Baltimore0.619
83/03/2024San Francisco0.333
93/14/24Cleveland0.286
101 Day Off
1123/03/2024Texas0.667
1224/03/2024Arizona0.476
1331/03/2024Kansas City0.429
144/07/2024New York (N)0.571
Averageifs
Cell Formulas
RangeFormula
E4E4=AVERAGEIFS(C4:C14, A4:A14, "<" & A1, C4:C14, "<>")
F4F4=AVERAGEIFS(C4:C14,A4:A14,"<"&A1)
 
Upvote 0
How about this?

Book4
ABCDE
13/23/24
2Boston
3DateTeamPCTResult
42/12/24New York (A)0.3810.435
52/17/24Toronto0.556
61 Day Off
72/21/24Baltimore0.619
83/3/24San Francisco0.333
93/14/24Cleveland0.286
101 Day Off
113/23/24Texas0.667
123/24/24Arizona0.476
133/31/24Kansas City0.429
144/7/24New York (N)0.571
Sheet1
Cell Formulas
RangeFormula
E4E4=AVERAGEIFS(C4:C14, A4:A14, "<" & A1, C4:C14, "<>")

What formula were you using?
Do you actually need the extra condition in the AVERAGEIFS formula? Do you have circumstances where the shorter formula below would not work?
If so, could we have some sample data with XL2BB?

24 03 24.xlsm
ABCDEF
123/03/2024
2Boston
3DateTeamPCTResult
412/02/2024New York (A)0.3810.472250.47225
517/02/2024Toronto0.556
61 Day Off
721/02/2024Baltimore0.619
83/03/2024San Francisco0.333
93/14/24Cleveland0.286
101 Day Off
1123/03/2024Texas0.667
1224/03/2024Arizona0.476
1331/03/2024Kansas City0.429
144/07/2024New York (N)0.571
Averageifs
Cell Formulas
RangeFormula
E4E4=AVERAGEIFS(C4:C14, A4:A14, "<" & A1, C4:C14, "<>")
F4F4=AVERAGEIFS(C4:C14,A4:A14,"<"&A1)
Strength of Schedule SNBL.xlsx
ABCD
34Boston
35DateTeamPCTSOS
362/11/24New York (A).381.596
372/18/24Toronto.524.482
381 Day Off
392/25/24Baltimore.619.524
403/3/24San Francisco.333.545
413/10/24Cleveland.286.457
421 Day Off
433/17/24Texas.619.375
443/24/24Arizona.476.553
453/31/24Kansas City.429.562
464/7/24New York (N).571.420
Standings_SOS
Cell Formulas
RangeFormula
C36:C37,C43:C46,C39:C41C36=VLOOKUP(B36,$A$2:$D$32,4,FALSE)
D36:D37,D43:D46,D39:D41D36=VLOOKUP(B36,$A$2:$M$32,13,FALSE)
 
Upvote 0
Strength of Schedule SNBL.xlsx
ABCD
34Boston
35DateTeamPCTSOS
362/11/24New York (A).381.596
372/18/24Toronto.524.482
381 Day Off
392/25/24Baltimore.619.524
403/3/24San Francisco.333.545
413/10/24Cleveland.286.457
421 Day Off
433/17/24Texas.619.375
443/24/24Arizona.476.553
453/31/24Kansas City.429.562
464/7/24New York (N).571.420
Standings_SOS
Cell Formulas
RangeFormula
C36:C37,C43:C46,C39:C41C36=VLOOKUP(B36,$A$2:$D$32,4,FALSE)
D36:D37,D43:D46,D39:D41D36=VLOOKUP(B36,$A$2:$M$32,13,FALSE)
Strength of Schedule SNBL.xlsx
ABCD
637/7/24Oakland.524.472
647/14/24St. Louis.571.531
657/21/24Kansas City.429.562
667/28/24Seattle.333.575
671 Day Off
688/4/24Miami.500.546
698/11/24Milwaukee.684.401
708/18/24Minnesota.524.403
718/25/24Los Angeles (A).524.571
721 Day Off
739/1/24Cincinnati.455.539
749/8/24Detroit.571.500
759/15/24New York (A).381.596
761 Day Off
779/22/24Toronto.524.482
789/29/24Baltimore.619.524
79Strength of schedule played>.460.496
Standings_SOS
Cell Formulas
RangeFormula
C63:C66,C77:C78,C73:C75,C68:C71C63=VLOOKUP(B63,$A$2:$D$32,4,FALSE)
D63:D66,D77:D78,D73:D75,D68:D71D63=VLOOKUP(B63,$A$2:$M$32,13,FALSE)
C79C79=AVERAGEIFS(C$36:C$78, A$36:A$78, "<" & $A$33, C$36:C$78, "<>")
D79D79=AVERAGEIFS(D$36:D$78, A$36:A$78, "<" & $A$33, D$36:D$78, "<>")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B62:B78,E62:E78,H62:H78,K62:K78,N62:N78,Q62:Q78,B108:B124,E108:E124,H108:H124,K108:K124,N108:N124,Q108:Q124,B154:B170,E154:E170,H154:H170,K154:K170,N154:N170,Q154:Q170Expression=D62>=0.5textNO
 
Upvote 0
Thanks for getting XL2BB going.

Your layout is different to the layout shown in post 1.

Also, your XL2BB sample does not show all the information that the formulas refer to. Can you make up a much smaller example that shows the issue and post that with XL2BB?
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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