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
|
Sub DoublonsEntre2ColonnesNoLignesCommentaire()
Set f1 = Sheets("feuil1")
Set f2 = Sheets("feuil2")
Set d = CreateObject("Scripting.Dictionary")
couleurs = Array(3, 4, 6, 7, 8, 15, 17, 20, 22, 24, 26, 27, 28, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 50, 53)
Set plage1 = f1.Range("a2:a" & f1.[a65000].End(xlUp).Row)
Set plage2 = f2.Range("d2:d" & f2.[d65000].End(xlUp).Row)
plage1.ClearComments
plage2.ClearComments
plage1.Interior.ColorIndex = xlNone
plage2.Interior.ColorIndex = xlNone
For Each c In plage1
d.Item(c.Value) = d.Item(c.Value) & c.Row & "-"
Next c
For Each c In plage2
If d.exists(c.Value) Then
If c <> "" Then
nocoul = (Application.Match(c.Value, d.keys, 0)) Mod UBound(couleurs)
c.Interior.ColorIndex = couleurs(nocoul)
a = Split(d.Item(c.Value), "-")
For k = LBound(a) To UBound(a) - 1
tmp = a(k) - plage1.Row + 1
plage1(tmp).Interior.ColorIndex = couleurs(nocoul)
Next k
c.AddComment
temp = CStr(d.Item(c.Value))
c.Comment.Text Text:=Left(temp, Len(temp) - 1)
c.Comment.Shape.OLEFormat.Object.Font.Size = 7
c.Comment.Shape.Left = c.Offset(, 1).Left + 10
c.Comment.Shape.TextFrame.AutoSize = True
c.Comment.Visible = True
End If
End If
Next c
'--
Set d = CreateObject("Scripting.Dictionary")
For Each c In plage2
d.Item(c.Value) = d.Item(c.Value) & c.Row & "-"
Next c
For Each c In plage1
If d.exists(c.Value) Then
c.AddComment
temp = CStr(d.Item(c.Value))
c.Comment.Text Text:=Left(temp, Len(temp) - 1)
c.Comment.Shape.OLEFormat.Object.Font.Size = 7
c.Comment.Shape.Left = c.Offset(, 1).Left + 10
c.Comment.Shape.TextFrame.AutoSize = True
c.Comment.Visible = True
End If
Next c
End Sub |
Partager