Oct 25 2017 01:37 AM
Hi everyone,
I have a problem I can not solve by myself.
Maybe somebody can help me.
I have an excel workbook with 9 sheets. Every sheets is for another section of my company.
This workbook belongs to 2017. Now it has to be created a new one for 2018.
The workbooks handle employees overtime, from column "e-r" are monthly overtime inscribed.
In every row another employee, in column "d" is it possible to substract reduced overtime (e.g. with freetime).
Following code is used in every single sheet (Example):
Sub OvertimereduceSec21() Dim LeZe As Long Dim n As Single Dim i As Single Dim Dneu As Single LeZe = ThisWorkbook.Worksheets("Sec11").Cells(Rows.Count, 4).End(xlUp).Row For n = 4 To LeZe 'Zeilen Dneu = Cells(n, 4) For i = 5 To 18 ' column E bis R If Dneu <= Cells(n, i) Then Cells(n, i) = Cells(n, i) - Dneu Dneu = 0 Else Dneu = Dneu - Cells(n, i) Cells(n, i) = 0 End If Next i Cells(n, 4) = 0 Next n End Sub
My problem is:
In WB 2018 this code has to start in the sheet of 2017 and go on in 2018 when in 2017 is no more overtime.
My idea: Copy the Sheets from wb2017 into wb2018 and hide them. Then fix the code to begin in wb2017.sec21 and continue in wb2018.sec21.
But I do not know how to fix the code to substract over two sheets.
I hope somebody unterstand what I mean and is willing to give me the determmining tip.
Regards,
Andre