Sub Mancanti()
Application.ScreenUpdating = False
Dim x, y, match As Boolean
Dim arr As Variant
Dim stNow As Date
stNow = Now
Sheets("report").Range("L2:O" & Range("A" & Rows.Count).End(xlUp).Row).ClearContents
arr = Sheets("dati").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Value
varr = Sheets("report").Range("K2:K" & Range("k" & Rows.Count).End(xlUp).Row).Value
For Each x In arr
match = False
For Each y In varr
If x = y Then match = True
Next y
If Not match Then
Sheets("report").Range("L" & Range("L" & Rows.Count).End(xlUp).Row + 1) = x
Sheets("report").Range("M" & Range("M" & Rows.Count).End(xlUp).Row + 1) = Sheets("dati").Cells(x, 1).Offset(, 1)
Sheets("report").Range("N" & Range("N" & Rows.Count).End(xlUp).Row + 1) = Sheets("dati").Cells(x, 1).Offset(, 2)
Sheets("report").Range("O" & Range("O" & Rows.Count).End(xlUp).Row + 1) = Sheets("dati").Cells(x, 1).Offset(, 3)
End If
Next
Application.ScreenUpdating = True
End Sub
'-----------------------------------------------------------------------------------------------------------------------------------------
Sub Xx()
Dim v1, v2, V3(), i As Long, j As Long
Application.ScreenUpdating = False
'progressivo colonna A
With Sheets("report")
v = 1
For i = 2 To Sheets("report").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("report").Cells(i, 1).Value = v
v = v + 1
Next
End With
Call Mancanti
a_LastRow = Sheets("report").Cells(Sheets("report").Rows.Count, 12).End(xlUp).Row + 1
For i = a_LastRow - 1 To 2 Step -1 ' header row 1
'For i = 2 To Sheets("report").Cells(Sheets("report").Rows.Count, "L").End(xlUp).Row + 1
x1x = Sheets("report").Cells(i, 12)
x1xdataNumero = Sheets("report").Cells(i, 13)
x1xdata = Sheets("report").Cells(i, 14)
x1xdataDescrizione = Sheets("report").Cells(i, 15)
Const col = 11
Dim sht As Worksheet
Set sht = Sheets("report")
rngVal = Range(IIf(IsEmpty(Cells(2, col)), Cells(2, col).End(xlDown), Cells(2, col)), Cells(sht.Rows.Count, col).End(xlUp)).Address
rngName = Range(IIf(IsEmpty(Cells(2, col)), Cells(2, col).End(xlDown), Cells(2, col)), Cells(sht.Rows.Count, col).End(xlUp)).Address
xMax = Evaluate("MAX(IF(" & rngName & "<" & x1x & "," & rngVal & "))")
xmin = Evaluate("MIN(IF(" & rngName & ">" & x1x & "," & rngVal & "))")
ur = Sheets("report").Cells(Rows.Count, 1).End(xlUp).Row + 1
n_rMax = Application.match(xMax, Sheets("report").Range("k2:k" & ur), 1) + 1
Sheets("report").Cells(n_rMax + 1, "A").EntireRow.Insert
Sheets("report").Cells(n_rMax + 1, "A") = x1xdataNumero
Sheets("report").Cells(n_rMax + 1, "B") = CDate(x1xdata)
Sheets("report").Cells(n_rMax + 1, "D") = x1xdataDescrizione
Sheets("report").Cells(n_rMax + 1, "C") = "FT_" & x1x
Sheets("report").Cells(n_rMax + 1, "J") = x1xdataNumero
Sheets("report").Cells(n_rMax + 1, "k") = x1x
Next
'progressivo colonna A
With Sheets("report")
v = 1
For i = 2 To Sheets("report").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("report").Cells(i, 1).Value = v
v = v + 1
Next
End With
Application.ScreenUpdating = True
End Sub