1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Sub galopin()
Dim iLRA%, iLRN%, i%, j%, k%
Dim Y As Boolean, Ys As Boolean, Yr As Boolean
Dim TabloA(), TabloN(), TabloB(), TabloC()
Dim WbA As Workbook, WbN As Workbook
Dim WsA As Worksheet, WsN As Worksheet
'Détermination du nombre de ligne de Classeur "Ancien" et "Nouveau"
Set WbA = Workbooks("OPTIM BASE CLIENTS 26 décembre 2008.xls")
Set WbN = Workbooks("OPTIM BASE CLIENTS 20 février 2009.xls")
Set WsA = WbA.Worksheets(1)
Set WsN = WbN.Worksheets(1)
iLRA = WsA.Cells(65535, 1).End(xlUp).Row
iLRB = WsN.Cells(65535, 1).End(xlUp).Row
TabloA() = WsA.Range("A1:A" & iLRA)
TabloN() = WsN.Range("A1:A" & iLRB)
TabloB() = WsB.Range("E1:E" & iLRA)
TabloC() = WsC.Range("E1:E" & iLRB)
'Détermination des absents
For i = 1 To UBound(TabloA)
For j = 1 To UBound(TabloN) 'Si égalité alors on pose un drapeau
If TabloN(j, 1) = TabloA(i, 1) Then
Y = True
For s = 1 To UBound(TabloB)
For u = 1 To UBound(TabloC)
If TabloB(s, 1) = TabloC(u, 1) Then
Yr = True
'et on vérifie la ligne si c'est une égalité stricte
For k = 1 To 15
If WsA.Cells(i, k) <> WsN.Cells(j, k) Then 'si différence on pose un drapeau
If WsA.Cells(s, k) <> WsN.Cells(u, k) Then
Ys = True
WsN.Cells(j, k).Interior.ColorIndex = 45 'et on colorie en orange
End If
End If
Next
WsN.Cells(u, 1).Interior.ColorIndex = IIf(Ys, 45, 4) 'sinon 1ere cellule en vert
Ys = False
Exit For
End If
Next
WsN.Cells(u, 1).Interior.ColorIndex = IIf(Yr, 46, 4)
Yr = False
Exit For
End If
'Si pas trouvé alors on colorie en rouge
If Not Y Then WsA.Range("A" & i).Interior.ColorIndex = 3
Y = False
Next
Set WbA = Nothing
Set WbN = Nothing
Set WsA = Nothing
Set WsN = Nothing
End Sub |
Partager