Private Sub CompareColumns()
Dim rngA As Range
Dim rngB As Range
Dim StrEv As String
Dim StrSty, StrFab, StrDep, StrSubd, StrClas, StrSubCl As String
Dim NewEvent() As String
Dim NewStyle() As String
Dim NewFabric() As String
Dim NewDept() As String
Dim NewSubDept() As String
Dim NewClass() As String
Dim NewSubCls() As String
Dim m As Integer
i = 0
Sheets("Old").Select
Columns("H").Copy
Sheets("New").Select
Range("I1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Set rngA = Sheets("New").Range(Cells(1, "H"), Cells(Rows.Count, "H").End(xlUp))
Set rngB = Sheets("New").Range(Cells(1, "I"), Cells(Rows.Count, "I").End(xlUp))
For Each cell In rngA
If IsError(Application.Match(cell.Value, rngB, 0)) Then
StrEv = StrEv & Cells(cell.Row, "A").Value & ";"
StrSty = StrSty & Cells(cell.Row, "F").Value & ";"
StrFab = StrFab & Cells(cell.Row, "G").Value & ";"
StrDep = StrDep & Cells(cell.Row, "B").Value & ";"
StrSubd = StrSubd & Cells(cell.Row, "C").Value & ";"
StrClas = StrClas & Cells(cell.Row, "D").Value & ";"
StrSubCl = StrSubCl & Cells(cell.Row, "E").Value & ";"
End If
Next
NewEvent = Split(StrEv, ";")
NewStyle = Split(StrSty, ";")
NewFabric = Split(StrFab, ";")
NewDept = Split(StrDep, ";")
NewSubDept = Split(StrSubd, ";")
NewClass = Split(StrClas, ";")
NewSubCls = Split(StrSubCl, ";")
Sheets("Check").Select
Range("A1000").End(xlUp).Offset(1, 0).Select
m = UBound(NewEvent) ' Calcolo la lunghezza delle Matrici
For i = 0 To m
Selection.Value = NewEvent(i)
ActiveCell.Offset(0, 1).Value = NewStyle(i)
ActiveCell.Offset(0, 2).Value = NewFabric(i)
ActiveCell.Offset(0, 3).Value = NewDept(i)
ActiveCell.Offset(0, 4).Value = NewSubDept(i)
ActiveCell.Offset(0, 5).Value = NewClass(i)
ActiveCell.Offset(0, 6).Value = NewSubCls(i)
ActiveCell.Offset(1, 0).Select
Next i
End Sub
|