1 pièce(s) jointe(s)
Bug de ma macro sur une ligne(résolu)
Bonjour à tous,
J'ai fait une macro avec les chiffres en format "texte" pour éviter les doublons dans un tableau hors il y a une ligne pourtant correct ( If .Cells(9, k) = .Cells(i, j) Then)qui n'est pas pris en compte !
Pouvez-vous m'expliquer !
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
Option Explicit
Sub test()
Dim i As Long, j As Long, k As Long
With Sheets("Feuil1")
Range("A9:I9") = ""
For i = 1 To 6
For j = 1 To 3
.Cells(i, j).NumberFormat = "@"
For k = 1 To 9
.Cells(9, k).NumberFormat = "@"
If .Cells(9, k) = .Cells(i, j) Then ' n'est pas pris en compte
Exit For
ElseIf .Cells(9, k) <> .Cells(i, j) And .Cells(9, k) = "" Then
.Cells(9, k) = .Cells(i, j)
Exit For
End If
Next k
Next j
Next i
End With
End Sub |
Bonne soirée