This is not working because I didn't write it correctly
This still is not working. I tested things by doing all of the following.
1. Copy the formula in the workbook.
2. Place a 0 in every A99 cell for a sheet that should have this happen.
3. Save and close.
4. Reset the windows clock to think that the date is January 17, 2006.
5. Reopen the workbook and wait for the system to process everything that it
is going to.
6. Cross fingers.
7. Check a sheet to see if the copy and paste has occured.
8. Find that it has not and curse.
Here is the code that I have in place.
Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
'pick employee record to evaluate rather than master and system Sheets
With wks
If LCase(.Name) = "master" Or _
LCase(.Name) = "employee census" Or _
LCase(.Name) = "vac&sick" Then
' do nothing
ElseIf .Range("C5").Value < DateSerial(2005, 1, 1) Or _
.Range("C5").Value < Now - 1 Then
' Determine if the employee uses the first of the year or
' if not then determine if the copy should be done or not
If .Range("A99").Value = 0 Then
.Range("A7:F34").Copy .Range("A100")
.Range("A7:F34").ClearContents
.Range("A99").Value = 1
End If
End If
End With
Next wks
End Sub
Note that the value in C5 should be less than the value of 01/01/2005 to
trigger the first condition.
Note that if the value of A99 is 1 then nothing should happen since the last
action sets A99 to 1.
This does not seem to be doing anything on open. Is Sub Workbook_Open() the
right command? Should this be a private sub instead?
Leonard
|