Option Explicit
Sub controlla()
Dim ws1 As Worksheet: Set ws1 = Sheets("Foglio1")
Dim ws2 As Worksheet: Set ws2 = Sheets("Foglio2")
Dim ws3 As Worksheet: Set ws3 = Sheets("Foglio3")
Dim Area1 As Range, Area2 As Range
Dim Uriga1 As Long, Uriga2 As Long, R As Long
Dim Nome As String, Riga As Object, Cella As Range
Uriga1 = ws1.Range("A" & Rows.Count).End(xlUp).Row
Uriga2 = ws1.Range("A" & Rows.Count).End(xlUp).Row
Set Area1 = ws1.Range("A1:A" & Uriga1)
Set Area2 = ws2.Range("A1:A" & Uriga2)
R = 1
For Each Cella In Area1
Nome = Cella.Value
Set Riga = Area2.Find(Nome, LookIn:=xlValues, LookAt:=xlWhole)
If Riga Is Nothing Then
ws3.Cells(R, 1) = Cella
ws3.Cells(R, 2) = "NON Presente"
R = R + 1
End If
Next Cella
For Each Cella In Area2
Nome = Cella.Value
Set Riga = Area1.Find(Nome, LookIn:=xlValues, LookAt:=xlWhole)
If Riga Is Nothing Then
ws3.Cells(R, 1) = Cella
ws3.Cells(R, 2) = "Nuovo"
R = R + 1
End If
Next Cella
Set ws1 = Nothing
Set ws2 = Nothing
Set ws3 = Nothing
Set Area1 = Nothing
Set Area2 = Nothing
MsgBox " Fatto"
End Sub
|