Sub Nuovicode()
't = Timer
Set ws3 = Sheets("OGGI")
Set ws1 = Sheets("IERI")
Set ws2 = Sheets("NUOVO/VECCHIO")
ur = ws3.Cells(ws3.Rows.Count, "A").End(xlUp).Row
ur2 = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
Set Area2 = ws1.Range("E1:E" & ur2)
Application.ScreenUpdating = False
ws2.Range("D2:E5000").Clear
ws3.Range("E1:E" & ur).AdvancedFilter Action:=xlFilterInPlace, Unique:=True
ws1.Range("E1:E" & ur).AdvancedFilter Action:=xlFilterInPlace, Unique:=True
Set Area1 = ws3.Range("E1:E" & ur).SpecialCells(xlCellTypeVisible)
Set Area2 = ws1.Range("E1:E" & ur2) '.SpecialCells(xlCellTypeVisible)
Set Rating1 = ws3.Range("Z1:Z" & ur).SpecialCells(xlCellTypeVisible)
Set Rating2 = ws1.Range("Z1:Z" & ur2) '.SpecialCells(xlCellTypeVisible)
R = 1
For Each Cella In Area1
'R = R + 1
If Application.CountIf(Area2, Cella) = 0 Then
R = R + 1
ws2.Cells(R, 4) = Cella
ws2.Cells(R, 5) = "Nuovo codice"
End If
Next Cella
R = 1
For i = 2 To ur
For j = 2 To ur2
If Area1(i, 1) = Area2(j, 1) Then
If Rating1(i, 1) <> Rating2(j, 1) Then
R = R + 1
ws2.Cells(R, 7) = Cella
ws2.Cells(R, 8) = "Nuova classe"
ws2.Cells(R, 9) = Rating1(i, 1)
ws2.Cells(R, 10) = Rating2(j, 1)
End If
End If
Next j
Next i
If ws3.FilterMode Then
ws3.ShowAllData
End If
If ws1.FilterMode Then
ws1.ShowAllData
End If
Application.ScreenUpdating = True
Set ws1 = Nothing
Set ws3 = Nothing
Set Area1 = Nothing
Set Area2 = Nothing
'MsgBox Timer - t
End Sub
|