Sub InTEMPO(y As Integer, z As Integer)
Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim L As Integer
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim WS3 As Worksheet
Set WS1 = Active.Worksheet.Name 'QUESTA è LA MIA PROVA, MA CHIARAMENTE NON FUNGE
Set WS2 = Worksheets("Disegni")
Set WS3 = Worksheets("Parametri")
Select Case UCase(Cells(y, 8 + z))
Case ("DISTENSIONE")
J = WS3.Cells(2, 2)
Case ("TAGLIO A 1/2")
J = WS3.Cells(2, 3)
Case ("DISTENSIONE+TAGLIO")
J = WS3.Cells(2, 4)
Case ("")
J = 0
End Select
Select Case Weekday(Cells(y, 15 + z))
Case 6, 2
L = 3
Case 3
L = 2
Case 4, 7, 1
L = 1
Case 5
L = 0
End Select
'k = gg colllaudo
K = WS3.Cells(2, 5).Value
'I = gg imballaggio
I = Application.WorksheetFunction.VLookup(UCase(Cells(y, 4 + z)), WS2.Range("a:af"), 32, False)
WS1.Activate
'colonna Q DATA APPRONTAMENTO -----> data consegna - imballo, controllando che non sia sabato o domenica.
If Weekday(DateAdd("d", -I, WS1.Cells(y, 18 + z))) = 7 Then
Cells(y, 17 + z) = DateAdd("d", -I - 1, WS1.Cells(y, 18 + z))
ElseIf Weekday(DateAdd("d", -I, WS1.Cells(y, 18 + z))) = 1 Then
Cells(y, 17 + z) = DateAdd("d", -I - 2, WS1.Cells(y, 18 + z))
Else: Cells(y, 17 + z) = DateAdd("d", -I, WS1.Cells(y, 18 + z))
End If
'COLONNA P DATA APPRONTAMENTO GIORNO
If Cells(y, 21 + z) = "morandini" Then
Cells(y, 16 + z) = DateAdd("d", -L, WS1.Cells(y, 17 + z))
Else: Cells(y, 16 + z) = Cells(y, 17 + z)
End If
'COLONNA O DATA PER DISTENSIONE E TAGLIO
If Weekday(DateAdd("d", -J, WS1.Cells(1, 8))) = 1 Then
Cells(y, 15 + z) = DateAdd("d", -J - 2, WS1.Cells(1, 8))
ElseIf Weekday(DateAdd("d", -J, WS1.Cells(1, 8))) = 7 Then
Cells(y, 15 + z) = DateAdd("d", -J - 1, WS1.Cells(1, 8))
Else: Cells(y, 15 + z) = DateAdd("d", -J, WS1.Cells(1, 8))
End If
'COLONNA N, DATA COLLAUDO
If Weekday(DateAdd("d", -K, WS1.Cells(y, 15 + z))) = 1 Then
Cells(y, 14 + z) = DateAdd("d", -K - 2, WS1.Cells(y, 15 + z))
ElseIf Weekday(DateAdd("d", -K, WS1.Cells(y, 15 + z))) = 7 Then
Cells(y, 14 + z) = DateAdd("d", -K - 1, WS1.Cells(y, 15 + z))
Else: Cells(y, 14 + z) = DateAdd("d", -K, WS1.Cells(y, 15 + z))
End If
'WS1.Range ("C+z" & (y + 1))
End Sub
|