Hi All,
I have this code I am trying to get to work. I have a time sheet for all employees and want to automate the process a bit.
On Worksheet "Employee" I have 3 columns(Employee Number(A), Employee Name(B), Area(C). I am trying to fill in the time sheet with each employee and print it out then move to the next one...and so on.
Any help would be great. Z
I have this code I am trying to get to work. I have a time sheet for all employees and want to automate the process a bit.
On Worksheet "Employee" I have 3 columns(Employee Number(A), Employee Name(B), Area(C). I am trying to fill in the time sheet with each employee and print it out then move to the next one...and so on.
Code:
Sub RunPrint()
Dim Employee As Range
Dim EmployeeName As String
Dim WeekStart As Date
Dim WeekEnd As Date
Dim Area As String
WeekStart = InputBox("Please enter week beginning date. **/**/**")
WeekEnd = WeekStart + 6
For Each Employee In Worksheets("Employee").Range("A2:A65536")
With Employee
If Employee = True Then
If Range(Employee, 3) = "P/C" Then
Worksheets("TimeSheet").Cells("N1") = ("EMPLOYEE NAME: " & EmployeeName & " " & EmployeeNumber)
Worksheets("TimeSheet").Cells("A3") = ("WEEK BEGINNING: " & WeekStart)
Worksheets("TimeSheet").Cells("N3") = ("WEEK ENDING: " & WeekEnd & " " & Area)
Worksheets("TimeSheet").PrintOut Copies:=2
Else
Worksheets("TimeSheet").Cells("N1") = ("EMPLOYEE NAME: " & EmployeeName & " " & EmployeeNumber)
Worksheets("TimeSheet").Cells("A3") = ("WEEK BEGINNING: " & WeekStart)
Worksheets("TimeSheet").Cells("N3") = ("WEEK ENDING: " & WeekEnd & " " & Area)
Worksheets("TimeSheet").PrintOut Copies:=1
End If
End If
End With
Next Employee
End Sub
Any help would be great. Z