Calculating lost hours per week

gd6noob

Board Regular
Joined
Oct 20, 2017
Messages
170
Office Version
  1. 2016
Platform
  1. Windows
Hi there,

I have a worksheet that calculates lost hours for employees.
Basically it cells AE to CD are weeks 1 to 52 and it looks at the start and end date and spits the numbers according to the weeks for lost hours.
1590803051851.png

The reference to the Do Not Delete tab is
1590803355013.png


The issue is that when there are lots of entries, this slows the sheet down a lot. Is there a better more efficient way to count this?


What is more efficient way of coding this?

Thanks in advanced.
 

Attachments

  • 1590802928938.png
    1590802928938.png
    31.9 KB · Views: 53
  • 1590803176797.png
    1590803176797.png
    10.6 KB · Views: 54
That will probably make it easier, will take a look later.
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Trying to do what you wanted without the week columns wasn't working as well as I hoped. I've changed the week formulas so that they work with dates that start in the previous year or end in the next. I've also added in columns for week 53 as you had missed those.

I've changed some of the test dates and it works as I believe is correct.

 
Upvote 0
Yes this is working... Too bad the other way wasn't working. This is perfect thank you very much.
I just need to be careful with this as the week columns will includes hours from different years, so the data will be skewed a bit.

Thaank you for all your help, really appreciate it.
 
Upvote 0
I just need to be careful with this as the week columns will includes hours from different years, so the data will be skewed a bit.
That was my bad, I checked the dates with the week numbers but forgot to check if it was the correct year.

I'm not uploading the file again, attaching a file with a solution already in place goes against the forum rules. Given the volume and complexity of the earlier changes, I felt that it was a necessary evil, but this time it's just a single formula change.

This formula needs to go into AE3, then you will need to drag it right and down to fill the rest of the week columns. Note that you need to fill down manually, when you drag right in a table the existing rows below do not update automatically. Once the existing formulas have been filled correctly any new rows will be added automatically as before.

=IF(N($S3)=0,"",IF(AND($L3<='Do not Delete'!$E$3,$M3>EOMONTH('Do not Delete'!$E$3,-12),WEEKNUM(MAX($L3,EOMONTH('Do not Delete'!$E$3,-12)+1))<=VALUE(AE$2),WEEKNUM(MIN($M3,'Do not Delete'!$E$3))>=VALUE(AE$2)),$S3,""))
 
Upvote 0
I think maybe Im not doing this right, but the above formula, dates in 2020 do not fill in the weeks column.
 
Upvote 0
Based on the date in SEE Status B2 and Do Not Delete E3, I assumed that is was a a 2019 sheet and set it up based on that.

The date in E3 sets the end point of the date range to be used, e.g. 31/12/19 sets the range to 1/1/19-31/12/19
 
Upvote 0
Ahh yes.. I thought Do Not Delete E2 was the max end year... after changing E3 from 2019 to 2020, its working perfect.. I tried to enter start date as 10/1/2019 to 2/1/2020 and only 2020 weeks column is showing...

Thank you again for the help.
 
Upvote 0

Forum statistics

Threads
1,214,840
Messages
6,121,895
Members
449,058
Latest member
Guy Boot

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