WEEKDAY Calc to exclude empty cells

mnyankee

New Member
Joined
Mar 20, 2023
Messages
11
Office Version
  1. 365
Platform
  1. Windows
I have a created a "template" spreadsheet which contains three total rows at the top. The user copies and pastes an entire month of data into the rows below total rows and the formulas do the rest. The totals use the weekday formula to sum up the data by weekday and weekend. I have my calc range to be 31 rows because that is the most a month can have. For months containing less than 31 days, the issue I have run into on my average calculations is that for the weekends, it is including empty rows in the calculation. I have done a lot of research and the weekday calc reverts to Saturday if the cell is blank and thus adds extra "days" to divide by to get the average. So my question is how can I change my formula to automatically figure out what the last row of data is in order to not include empty cells. Note this only applies to when using the average calculation. For this example I have narrowed down my data to 13 rows. My formula in D4 is: =AVERAGE(IF(WEEKDAY($A$5:$A$20,2)>5,D5:D20)). Apologies for posting a picture but I do not have rights to install XL2BB on my computer.

1679342032759.png
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi & welcome to MrExcel.
How about
Excel Formula:
=AVERAGE(IF((WEEKDAY($A$5:$A$20,2)>5)*(A5:A20<>""),D5:D20))
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0
You're welcome & thanks for the feedback.
I hate to bother you again but would you mind breaking down what your formula is doing? In particular, what is the * (A5:A20<>"") doing? I think it is looking for blanks but what does the * mean?
 
Upvote 0
The * means to multiply & (A5:A20<>"") is checking the cells are not blank.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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