Formula or VBA to track pro-rated attendance hours

bh24524

Active Member
Joined
Dec 11, 2008
Messages
365
Office Version
  1. 365
  2. 2007
Hi, I'm looking for some help with a scenario regarding employees who have completed a probationary period of employment. When this happens, they fall under the company attendance policy for unexcused absences or late arrivals. In a normal circumstance, someone would be entitled to 104 hours that they can use between all types of unexcused absences, late arrivals, leaving early or whatever the case may be where they end up not working their full shift. This is a process that resets every March where hours are erased and people have the full 104 allotment. If however someone completes their probation period AFTER March, they earn pro-rated hours the first day of every month until the following March. That pro-ration schedule is as follows:

1721827211636.png


I have a spreadsheet that lists specific dates that employees completed probation. These dates are in column J. Ideally, I'd like to have another column that automatically updates the hour values on the first of every month and that could be in column I. Whether this would be better done by VBA or by some kind of formula, I'm not sure.

Here are a couple examples. Let's say we have one person completing probation in June(Person 1) and another completing in July(Person 2).

EXAMPLE 1
Person 1, I'd expect in June to see column I auto-populate 8.8 hours, July 1 would populate 17.6 hours(8.8+8.8), and August 1 would populate 26.4 hours (8.8+8.8+8.8)

EXAMPLE 2
Person 2 I'd expect in July to see column I auto-populate 8.7 hours and then on August 1, they would get 17.4 hours (8.7+8.7), so I would auto-update to 17.4.

Could something also be somehow incorporated that either the cell that is updating the value every month lights up a different color maybe the first few days of every month or maybe even a pop-up message upon the workbook opening at that time alerts that a value has been updated?

Note it doesn't matter when in the month someone completes their probations, if it is completed in that month, they get the allotment for that month.
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Sorry, I received new info because I was confused on what was provided to me in the screenshot I sent. It should only look like this:

1721831066404.png


That additional column was the OLD policy and meant to be a before/after pic of policies, so it has no relevance here.
 
Upvote 0
Is this what you need?:

For testing I added some "current date" columns (K:S):

Freq.xlsx
ABCDEFGHIJKLMNOPQRSTUV
1Probation completion date01/06/202401/07/202401/08/202401/09/202401/10/202401/11/202401/12/202401/01/202501/02/2025
2Jun-248.817.626.435.24452.861.670.479.2Apr8.6
3Jul-24 8.717.426.134.843.552.260.969.6May8.7
4Aug-24  8.817.626.435.24452.861.6Jun8.8
5Sep-24   8.817.626.435.24452.8Jul8.7
6Oct-24    918273645Aug8.8
7Nov-24     9182736Sep8.8
8Dec-24      91827Oct9.0
9Jan-25       510Nov9.0
10Feb-25        5Dec9.0
11Jan5.0
12Feb5.0
Sheet4
Cell Formulas
RangeFormula
K2:S10K2=LET(h, $V$2:$V$12, s, SEQUENCE(11), start_i, MATCH(MONTH($J2), MONTH($U$2:$U$12), 0), end_i, MATCH(MONTH(K$1), MONTH($U$2:$U$12), 0), f, FILTER(h, s=start_i), n, end_i-start_i+1, r, f*n, IF(r<=0, "", r) )


your final formula would be this:
Freq.xlsx
ABCDEFGHIJKLMNOPQRSTUV
1HoursProbation completion date
217.6Jun-24Apr8.6
38.7Jul-24May8.7
4 Aug-24Jun8.8
5 Sep-24Jul8.7
6 Oct-24Aug8.8
7 Nov-24Sep8.8
8 Dec-24Oct9.0
9 Jan-25Nov9.0
10 Feb-25Dec9.0
11Jan5.0
12Feb5.0
Sheet4 (2)
Cell Formulas
RangeFormula
I2:I10I2=LET(h, $V$2:$V$12, s, SEQUENCE(11), start_i, MATCH(MONTH($J2), MONTH($U$2:$U$12), 0), end_i, MATCH(MONTH(TODAY()), MONTH($U$2:$U$12), 0), f, FILTER(h, s=start_i), n, end_i-start_i+1, r, f*n, IF(r<=0, "", r) )
 
Upvote 0
Solution
Wow, that is exactly what I needed and completely stumps me lol. I've never seen that formula before and never would have come up with that. Great job Felix! If you ever have some time to do so, would you mind breaking down that formula into explanation? No biggie if it's too much to explain - I just love learning new formulas and how they work. That is not urgent though, so you could take your time on that.

Just a heads up that I might be replying to this very soon once I get confirmation with an additional question. I had one person tell me that it is the first of every month that these employees would receive the hour entitlement and I have another person telling me no, it's a month from their probation completion date. They have to have a meeting to determine which is correct, but if it is determined that it goes a month from their completion date and not the first, will that require a dramatic alteration of your formula?
 
Upvote 0
Thanks for the feedback.

To your question on how the formula works.
First we use the LET function which lets you define variables (or names how MS calls them), in pairs of arguments, and the last argument is the returned value. You could read more on that here: LET Function

So the formula
Excel Formula:
=LET(a, 1, b, 2, a+b)
would assign 1 to variable a, 2 to variable b, and return a+b.
the values you assign to the variables can also be a formula like this:

Freq.xlsx
ABC
11214
Sheet9
Cell Formulas
RangeFormula
C1C1=LET(a, 3+A1, b, B1*5, a+b)


Then you need to know array formulas or dynamic array formulas. You can read about that here: Guidelines and examples of array formulas - Microsoft Support

Now to our formula.

Excel Formula:
=LET(
h, $V$2:$V$12, 
s, SEQUENCE(11),
start_i, MATCH(MONTH($J2), MONTH($U$2:$U$12), 0),
end_i, MATCH(MONTH(TODAY()), MONTH($U$2:$U$12), 0),
f, FILTER(h, s=start_i),
n, end_i-start_i+1,
r, f*n,
IF(r<=0, "", r)
)

we get the index number start_i from the probation completion date, and the index number end_i from todays month.
In f we store the hour number pero month (8.8 in our example for june).
n is the number of month we have to multiply by the hours.
and finally with the If statement we filter the values that are 0 or less.

Actually looking at the formula again, we could do this, no need for the sequence:
Excel Formula:
=LET(h, $V$2:$V$12,
start_i, MATCH(MONTH($J2), MONTH($U$2:$U$12), 0),
end_i, MATCH(MONTH(TODAY()), MONTH($U$2:$U$12), 0),
f, XLOOKUP(MONTH($J2), MONTH($U$2:$U$12), h, ,0),
n, end_i-start_i+1,
r, f*n,
IF(r<=0, "", r)
)
 
Upvote 0
Hi, I haven't forgotten about this, they were delayed in discussing how this should really work whether it's the 1st of each month or a month from the completion date. I'm thinking it will be some time next week, but I will post once I do get an answer.
 
Upvote 0
Okay, I did hear back on this and how we currently have it as entitling it at the beginning of the month is fine, so thank you very much for your help felix. There is another part to this that I wonder if it will require some VBA, but I will post that separate and later on. Thank you for the explanation too. That will give me some material to dig into with these formulas.
 
Upvote 0
nvm thought there was an error. had posted but it seems it is okay.
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,980
Members
452,540
Latest member
haasro02

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