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
|
Sub Comparaison()
Dim wk1 As Workbook ' Classeur 1
Dim wk2 As Workbook ' Classeur 2
Dim wk3 As Workbook ' Classeur de résultat
Set wk1 = Workbooks("Codes TAC - Octobre 06.xls")
Set wk2 = Workbooks.Open("C:\Documents and Settings\ghipeau\Bureau\PROJET 2\code tac\Codes TAC - 05 Dec 06.xls")
Set wk2 = Workbooks.Open("C:\Documents and Settings\ghipeau\Bureau\PROJET 2\code tac\resultatcomparaison.xls")
Dim rngMoisPrecedent As Range
Dim rngMoisEnCours As Range
Set rngMoisPrecedent = Feuil1.Range("a2:a10")
Set rngMoisEnCours = Feuil2.Range("a2:a10")
RechercheElements rngMoisPrecedent, rngMoisEnCours ' recherche des suppressions
RechercheElements rngMoisEnCours, rngMoisPrecedent ' recherche des ajout => inversion des plages
End Sub
Sub RechercheElements(PlageBase As Range, PlageRecherche As Range)
Dim Cellule As Range
Dim CelResultat As Range
For Each Cellule In PlageBase
Set CelResultat = PlageRecherche.Find(what:=Cellule.Value, LookIn:=xlValues, lookat:=xlWhole)
If CelResultat Is Nothing Then MsgBox Cellule.Value & " non trouvé"
Next Cellule
End Sub |
Partager