
Sub PROVA()
Application.ScreenUpdating = False
Dim rng()
Dim E As Long
Dim A As Double, B As Double, C As Double, D As Double
Dim K As Double, L As Double, M As Double, N As Double, O As Double
K = 4.16666666666667E-02
L = 0.958333333333333
M = 0.999988425925926
N = 0.166666666666667
O = 2.08333333333333E-02
Sheets("FREQUENZE").Select
Range("B6:B").NumberFormat = "[$-F400]h:mm:ss AM/PM"
rng = Range("E6:E" & Range("E" & Rows.Count).End(xlUp).Row)
ReDim arr(1 To UBound(rng, 1), 1 To 1)
A = rng(1, 1)
For E = 2 To UBound(rng, 1)
B = rng(E, 1)
C = rng(1, 2)
D = rng(E, 2)
If A > K And B < K Then
arr(E, 1) = B - A
ElseIf D = C And A > N And B > N And (B - A) < O Then
arr(E, 1) = B - A
ElseIf A > L And B < K Then
arr(E, 1) = M - A + B
ElseIf D > C And B < K And A > L Then
arr(E, 1) = B - A
Else: arr(E, 1) = ""
End If
A = B
Next
Range("B6:B" & Range("E" & Rows.Count).End(xlUp).Row) = arr
Application.ScreenUpdating = True
End Sub |
Sub calcola()
Dim i As Long
For i = 6 To Range("E" & Rows.Count).End(xlUp).Row
If Cells(i + 1, "E") >= Cells(i, "E") Then
Cells(i + 1, "B") = Cells(i + 1, "E") - Cells(i, "E")
Else
Cells(i + 1, "B") = Cells(i + 1, "E") + 1 - Cells(i, "E")
End If
Next i
For i = 6 To Range("S" & Rows.Count).End(xlUp).Row
If Cells(i + 1, "S") >= Cells(i, "S") Then
Cells(i + 1, "Q") = Cells(i + 1, "S") - Cells(i, "S")
Else
Cells(i + 1, "Q") = Cells(i + 1, "S") + 1 - Cells(i, "S")
End If
Next i
End Sub
|
in B6:: =ASS((F6+E6)-(F7+E7)) da trascinare in basso fino a dove serve in Q7:: =ASS((T7+S7)-(T6+S6)) da trascinare in basso fino a dove serve |
Sub calcola()
Dim i As Long
For i = 6 To Range("E" & Rows.Count).End(xlUp).Row
If Cells(i, "E") < 1 / 24 And Cells(i + 1, "E") < 1 / 24 Then
Cells(i + 1, "B") = Cells(i + 1, "E") - Cells(i, "E")
ElseIf Cells(i + 1, "F") = Cells(i, "F") And Cells(i, "E") > 4 / 24 And Cells(i + 1, "E") > 4 / 24 And _
Cells(i + 1, "E") - Cells(i, "E") < 1 / 48 Then
Cells(i + 1, "B") = Cells(i + 1, "E") - Cells(i, "E")
ElseIf Cells(i, "E") > 23 / 24 And Cells(i + 1, "E") < 1 / 24 Then
Cells(i + 1, "B") = (1 - (1 / 86400)) - Cells(i + 1, "E") + Cells(i, "E")
ElseIf Cells(i + 1, "F") > Cells(i, "F") And Cells(i, "E") > 23 / 24 Then
Cells(i + 1, "B") = Cells(i + 1, "E") - Cells(i, "E")
Else
Cells(i + 1, "B") = ""
End If
Next i
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 6 To Range("S" & Rows.Count).End(xlUp).Row
If Cells(i, "S") < 1 / 24 And Cells(i + 1, "S") < 1 / 24 Then
Cells(i + 1, "Q") = Cells(i + 1, "S") - Cells(i, "S")
ElseIf Cells(i + 1, "T") = Cells(i, "T") And Cells(i, "S") > 4 / 24 And Cells(i + 1, "S") > 4 / 24 And _
Cells(i + 1, "S") - Cells(i, "S") < 1 / 48 Then
Cells(i + 1, "Q") = Cells(i + 1, "S") - Cells(i, "S")
ElseIf Cells(i, "S") > 23 / 24 And Cells(i + 1, "S") < 1 / 24 Then
Cells(i + 1, "Q") = (1 - (1 / 86400)) - Cells(i + 1, "S") + Cells(i, "S")
ElseIf Cells(i + 1, "T") > Cells(i, "T") And Cells(i, "S") > 23 / 24 Then
Cells(i + 1, "Q") = Cells(i + 1, "S") - Cells(i, "S")
Else
Cells(i + 1, "Q") = ""
End If
Next i
'''''
End Sub
'SE E6<1.00.00 e E7<1.00.00 restituisci in B7 il risultato di E7-E6 altrimenti
'SE F7=F6 e E6>4.00.00 e E7>4.00.00 e la differenza tra E7 ed E6 è < 0.30.00 restituisci in B7 il risultato di E7-E6 altrimenti
'SE E6>23.00.00 e E7<1.00.00 restituisci in B7 il risultato di 23.59.59 - E6+E7 altrimenti
'SE F7>F6 e E7<1.00.00 e E6>23.00.00 restituisci in B7 il risultato di E7-E6 altrimenti lascia la cella vuota.
|
Sub calcola_Abs()
Dim i As Long
For i = 6 To Range("E" & Rows.Count).End(xlUp).Row
If Abs(Cells(i + 1, "E") + Cells(i, "F") - Cells(i, "E") - Cells(i, "F")) < 1 / 48 Then
Cells(i + 1, "B") = Abs(Cells(i + 1, "E") + Cells(i, "F") - Cells(i, "E") - Cells(i, "F"))
Else
Cells(i + 1, "B") = ""
End If
Next i
For i = 6 To Range("S" & Rows.Count).End(xlUp).Row
If Abs(Cells(i + 1, "S") + Cells(i, "T") - Cells(i, "S") - Cells(i, "T")) < 1 / 48 Then
Cells(i + 1, "Q") = Abs(Cells(i + 1, "S") + Cells(i, "T") - Cells(i, "S") - Cells(i, "T"))
Else
Cells(i + 1, "Q") = ""
End If
Next i
End Sub |
Sub FREQUENZE2()
Sheets("FREQUENZE").Select
Dim i As Long
For i = 6 To Range("E" & Rows.Count).End(xlUp).Row
If Cells(i, "E") < 1 / 24 And Cells(i + 1, "E") < 1 / 24 Then
Cells(i + 1, "B") = Cells(i + 1, "E") - Cells(i, "E")
ElseIf Cells(i + 1, "F") = Cells(i, "F") And Cells(i, "E") > 4 / 24 And Cells(i + 1, "E") > 4 / 24 And _
Cells(i + 1, "E") - Cells(i, "E") < 1 / 48 Then
Cells(i + 1, "B") = Cells(i + 1, "E") - Cells(i, "E")
ElseIf Cells(i, "E") > 23 / 24 And Cells(i + 1, "E") < 1 / 24 Then
Cells(i + 1, "B") = (1 - (1 / 86400)) - Cells(i, "E") + Cells(i + 1, "E")
ElseIf Cells(i + 1, "F") > Cells(i, "F") And Cells(i, "E") > 23 / 24 And Cells(i + 1, "E") < 1 / 24 Then
Cells(i + 1, "B") = Cells(i + 1, "E") - Cells(i, "E")
Else
Cells(i + 1, "B") = ""
End If
Next i
For i = 6 To Range("S" & Rows.Count).End(xlUp).Row
If Cells(i, "S") < 1 / 24 And Cells(i + 1, "S") < 1 / 24 Then
Cells(i + 1, "Q") = Cells(i + 1, "S") - Cells(i, "S")
ElseIf Cells(i + 1, "T") = Cells(i, "T") And Cells(i, "S") > 4 / 24 And Cells(i + 1, "S") > 4 / 24 And _
Cells(i + 1, "S") - Cells(i, "S") < 1 / 48 Then
Cells(i + 1, "Q") = Cells(i + 1, "S") - Cells(i, "S")
ElseIf Cells(i, "S") > 23 / 24 And Cells(i + 1, "S") < 1 / 24 Then
Cells(i + 1, "Q") = (1 - (1 / 86400)) - Cells(i, "S") + Cells(i + 1, "S")
ElseIf Cells(i + 1, "T") > Cells(i, "T") And Cells(i, "S") > 23 / 24 And Cells(i + 1, "S") < 1 / 24 Then
Cells(i + 1, "Q") = Cells(i + 1, "S") - Cells(i, "S")
Else
Cells(i + 1, "Q") = ""
End If
Next i
End Sub
|
