re
voila ce que j'ai fait comme code
je n'arrive pas a ajouter le 2ieme texte au premier
le premier text s'affiche correctement
mais a la 2ieme manip.....le premier text reste mais le 2ieme ne s'ajoute pas!!!
merci
Private Sub CommandButton1_Click()
' AjoutVN Macro verifie avant l'existance du châssis en stock, sinon il l'ajoute
Dim i As Integer
Dim a As Integer
Dim b As Integer
With Sheets("2013")
Application.ScreenUpdating = False
If Len(Me.TextBox1) <> 8 Then
MsgBox "Veuillez introduire les 8 derniers chiffres du châssis"
Exit Sub
End If
For i = 1 To Range("B1000000").End(xlUp).Row
If Cells(i, 2) = Val(Me.TextBox1.Value) Then
If Cells(i, 2).Interior.Color = 65535 Then
MsgBox ("Ce châssis existe déjà, je vais le mettre en stock local" & vbNewLine & "à la date d'aujourd'hui")
Cells(i, 2).Interior.Color = -4142
Cells(i, 1) = "t"
Cells(i, 3) = Range("J2")
On Error Resume Next
a = Range("B" & i).Comment.Text
On Error GoTo 0
If TextBox20 = True Then
With Range("B" & i)
.ClearComments
.AddComment
.Comment.Text Text:=a & Me.TextBox20.Value
End With
End If
Range("I2").Select
Exit Sub
End If
End If
Next i
For i = 1 To .Range("B1000000").End(xlUp).Row
'If Cells(I, 2) = Me.TextBox1 Then
If Range("B" & i).Value = Val(Me.TextBox1.Value) Then
Me.TextBox5.Value = Cells(i, 2)
Me.TextBox6.Value = " Pas encore affecté "
Me.TextBox7.Value = " Pas encore affecté "
Me.TextBox8.Value = " Pas encore affecté "
MsgBox ("Ce châssis existe déjà dans le stock ATTENTION!!")
Exit Sub
End If
Next i
For i = 1 To .Range("D1000000").End(xlUp).Row
If Cells(i, 4) = Val(Me.TextBox1.Value) Then
Me.TextBox5.Value = Cells(i, 4)
Me.TextBox6.Value = Cells(i, 7)
Me.TextBox7.Value = Cells(i, 5)
Me.TextBox8.Value = Cells(i, 6)
MsgBox ("Ce châssis est déjà livré ATTENTION!!")
Exit Sub
End If
Next i
Rows(8).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(8, 1) = "t"
Cells(8, 2) = Val(Me.TextBox1.Value)
Cells(8, 3) = .Range("J2")
Cells(8, 2).ClearComments
Cells(8, 2).AddComment
Cells(8, 2).Comment.Text Text:=TextBox20.Value
MsgBox ("Châssis ajouté dans le stock")
Cells(2, 9).Select
Application.ScreenUpdating = True
End With
Call InitListbox
Me.TextBox1.Value = ""
End Sub