
Public Function DATA_X(Data_f As Date, Ora_i As Date, Durata As Long, Sabato As String) Dim data_i As Date, Data_s As Date Dim Giorni As Long, i As Long data_i = Application.WorkDay(Data_f, -Int((Durata + 10) / 10)) Giorni = Data_f - data_i - 1 Data_s = data_i For i = 0 To Giorni If Weekday(Data_s + i) = 7 And UCase(Sabato) = "SI" Then data_i = data_i + 1 Next i DATA_X = data_i + Ora_i End Function |
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
Dim DataA1 As Date
Dim i As Long, v As Long
Dim Nriga As Long
'''''''''''''''
DataA1 = [A1]
Nriga = 2
On Error Resume Next
Application.EnableEvents = False
Range("A2:A35").ClearContents
For i = 2 To 35
Ricontrolla:
For v = 2 To 35
If DataA1 = Cells(v, "J") Then
DataA1 = DataA1 + 1
GoTo Ricontrolla
End If
Next v
If Weekday(DataA1) = [E2] Then
DataA1 = DataA1 + 1
GoTo Ricontrolla
End If
If Weekday(DataA1) = [F2] Then
DataA1 = DataA1 + 1
GoTo Ricontrolla
End If
Cells(Nriga, "A") = DataA1
Nriga = Nriga + 1
DataA1 = DataA1 + 1
Next i
Application.EnableEvents = True
End Sub
|
