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
| Sub Macro1()
Dim plgA As Range, plgB As Range, c As Range
Dim listA(), listB()
Dim i As Integer, x As Integer, col As Integer
Dim a As String, b As String, champ As Variant, sp As Variant
Set plgA = Sheets("Administration").Range("A2:A" & Sheets("Administration").Range("A65536").End(xlUp).Row)
Set plgB = Sheets("web").Range("A2:A" & Sheets("web").Range("A65536").End(xlUp).Row)
col = Sheets("Administration").Range("IV1").End(xlToLeft).Column
For Each c In plgA
'CONCATENER chaque cellule Colonne 1 à 4 de chaqu'une des lignes des tableau A et B
' et renseigne les listA et lisB, pour éviter les doublons
For i = 1 To col
a = a & "," & Sheets("Administration").Cells(c.Row, i)
b = b & "," & Sheets("web").Cells(c.Row, i)
Next
ReDim Preserve listA(i)
listA(x) = Right(a, Len(a) - 1)
a = ""
ReDim Preserve listB(i)
listB(x) = Right(b, Len(b) - 1)
b = ""
x = x + 1
Next
'vérifier si chaque item(champ) de listA est présente dans listB
'si non présente mets l'information sur la feuille résultat en commencant à la
'ligne 2
x = 2
For Each champ In listA()
If champ = Empty Then Exit Sub
If IsError(Application.Match(champ, listB, 0)) Then
sp = Split(champ, ",")
For i = 0 To col - 1
Sheets("résultat").Cells(x, i + 1) = sp(i)
Next
x = x + 1
End If
Next
End Sub |
Partager