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 VerifierDoublons(colB As Variant)
Set FInventaire = Workbooks(PremierFichier).Worksheets("Pieces")
FInventaire.Activate
Sheets("Pieces").Select
Dim cmdL As Variant
Dim LigX As Integer ' Ce sera la ligne à annulé
Dim NoCol As Integer
Dim NoLig As Long
Dim Valeur As Variant
NoCol = 2 'lecture de la colonne 2
With FInventaire
For NoLig = 2 To Split(.UsedRange.Address, "$")(4)
Valeur = .Cells(NoLig, NoCol)
If Valeur = colB Then
LigX = NoLig
End If
Next
cmdL = "cmdL" & LigX
.Cells(LigX, NoCol).Value = "ANNULÉ"
.Cells(LigX, NoCol + 2).Value = ""
.Cells(LigX, NoCol + 3).Value = ""
.Cells(LigX, NoCol + 4).Value = .Cells(LigX, NoCol + 4).Value - 1
.Cells(LigX, NoCol + 5).Value = .Cells(LigX, NoCol + 5).Value + 1
End With
Sheets("Pieces").cmdL.Select ' C'est ici que ça plante
Sheets("Pieces").cmdL.Visible = "False"
Set FInventaire = Nothing
End Sub |
Partager