Okay I have added the document you will see that at the bottom of the ("TRAINING MATRIX") sheet there is additional information where I have to sign the document after I have printed it but it must only stay at the ("TRAINING MATRIX") sheet (at the moment it moves the information to the ("Expired Medicals")sheet. The date that expires on the ("TRAINING MATRIX") sheet is the employee’s yearly medical that they must do every year so if the date is updated in the ("TRAINING MATRIX") sheet the name must be automatically removed from the ("Expired Medicals") sheet but must remain in the ("TRAINING MATRIX") sheet without making a second entry for that specific employee. The code must run while I am working with the document at the moment I have to run the code manually. You will also see on the ("Expired Medicals") sheet there appears to be a Colom G that must not be there. If it is possible I will also prefer it if the employees information can be copied to the ("Expired Medicals")sheet 30 days from expiration date and not when it has expired so that it gives me enough time to book them to go and do their new medicals before it expires.
If someone can help me I will appreciate it?
The code that I have so far is:
Private Sub Workbook_Open()
Dim lr As Long, lr2 As Long
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("TRAINING MATRIX")
Set s2 = Sheets("Expired Medicals")
lr = s1.Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = 4 To lr
lr2 = s2.Range("A" & Rows.Count).End(xlUp).Row
If s1.Range("H" & i) <= Date Then
Dim Res As Variant
On Error Resume Next
Err.Clear
Res = Application.WorksheetFunction.VLookup(s1.Range("B" & i), s2.Range("B1:B" & lr2), 1, False)
If Err.Number = 0 Then
Resume Next
Else
s1.Range("A" & i & ":H" & i).Copy s2.Range("A" & lr2 + 1)
End If
End If
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Bookmarks