getting excel to automatically update on the 1st of each month


Posted by May on December 27, 2001 3:29 PM

I'm working on a Vacation/Sick Leave spread sheet for my employer that will automatically add 4 hours of sick leave to each employee on the 1st of every month. Is this something that excel can do?

Posted by Gary Hewitt-Long on December 27, 2001 6:19 PM

Try this, there are neater ways though :o)

Public Sub FirstOfMonth()

FOM = Format(Date, "dd")
If FOM = 1 Then
Range("D1").Select ' Enter starting point in sheet
Do
OriginalTime = ActiveCell.Value
ActiveCell.FormulaR1C1 = (OriginalTime + "4")
ActiveCell.Offset(RowOffset:=1).Activate
Loop Until ActiveCell.Row = "200" 'Enter final point in sheet
End If
End Sub


Regards,

Gary Hewitt-Long

Posted by Gary Hewitt-Long on December 27, 2001 6:29 PM

I forgot to add, if you want this to be truly automatic, then you need to have excel run the code when it starts.
If the day does = 1 then you will need to add in extra code to open the workbook before running the Do Loop and then save before closing.

Or

If it's a workbook you open everyday, then add it between:

Sub Workbook_Open()

End Sub

Also if the 1st falls on a weekend and the machine isn't on, then you will also need to add extra code to check over three days, to see whether it has been executed yet, and if not then run the code.

HTH

Regards,

Gary Hewitt-Long

Posted by May on December 27, 2001 7:31 PM

THANK YOU - THANK YOU - THANK YOU!!!! It worked perfectly!!



Posted by May on December 27, 2001 7:44 PM


What should the code look like with the adjustments? I won't be opening it every day and I'm not sure what the code would be to have it check over three days incase the 1st lands on a weekend. I just copied and pasted the last set of codes you gave me and then made a few minor adjustments. I really appreciate all your help - I've been going nuts trying to figure this out.