Sub macro4()
Dim mymonth As String
mymonth = Application.Worksheets("drivers").Range("b1")
Application.ScreenUpdating = False
Select Case mymonth
Case "1"
Sheets("drivers").Select
Range("d5:d36").Copy
Sheets("overtime").Select
Range("b2:b50").Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
Application.CutCopyMode = False
Case "2"
Sheets("drivers").Select
Range("d5:d36").Copy
Sheets("overtime").Select
Range("c2:c50").Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
Application.CutCopyMode = False
End Select
End Sub
In the sheets "drivers" there is pivot table from which code copy column "working hours"(range d5:d36) to sheets "overtime". If case 1 paste to range b2:b50, if case 2 paste to range c2:c50 and etc.
Because data in pivot table not static sometimes list of employees and their
working hours is not correspond with list of employees in the sheet "overtime".
(range A2:A50). In this case code misinserting value of working hours.
for example: employee John is secondary in range b2:b50 in the sheets "overtime". He can be tertiary in the pivot table on the sheet "drivers" and this code their working hours paste another employee.
I need help, how can I add one condition in this code who will compare list of employees from sheets "overtime" with range of employees from pivot table in the sheets "drivers".
After that code will inserted value of working hours correct.
Thanks,