Incompatibilité de type
Bonjour,
J'essaye de créer une petite interface avec userform pour modifier des données dans une basse de donnée
J'ai un problème , un message d'erreur me signale une incompatibilité de type, qui conserne la variable "com". Je n'arrive pas a voir le problème. Merci de m'éclaircir ou de me proposer une alternative au problème.
Private Sub CommandButton1_Click()
'COMMENTAIRES SAVE
Dim NomSTCom As String
Dim Com As Long
Dim Lg As Long
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
NomSTCom = Me.ComboBox1.Value
LotSTCom = Me.ComboBox2.Value
With Sheets("Feuil1")
Lg = .Range("B" & Rows.Count).End(xlUp).Row + 1 ' 1ère ligne vide
'Set Com = .Columns(2).Find(NomSTCom, LookIn:=xlValues, LookAt:=xlWhole)
For Com = 6 To Range("B65536").End(xlUp).Row
If Cells(Com, "B") Like NomSTCom And Cells(Com, "A") = LotSTCom Then
If Not Com Is Nothing Then
'premier commentaire positif sur le sous traitant selectionnée dans la liste
.Cells(Com, "A") = LotSTCom
.Cells(Com, "C") = TextBox1
.Cells(Com, "D") = TextBox6
'deuxième commentaire positif sur le sous traitant selectionnée dans la liste
If Cells(Com, "B").Offset(1, 0) Like NomSTCom And Cells(Com, "A").Offset(1, 0) = LotSTCom Then
.Cells(Com, "A").Offset(1, 0) = LotSTCom
.Cells(Com, "C").Offset(1, 0) = TextBox2
.Cells(Com, "D").Offset(1, 0) = TextBox7
Else
If Me.TextBox2 <> "" Or Me.TextBox7 <> "" Then
.Cells(Lg, "A") = LotSTCom
.Cells(Lg, "B") = NomSTCom
.Cells(Lg, "C") = TextBox2
.Cells(Lg, "D") = TextBox7
Lg = Lg + 1
End If
End If
Bonsoir,
A priori je ne vois pas de souci. Mais je ne peux le tester car ton USF comporte un objet non lisible sous ma version excel.
Remplace toutefois
Range("B65536").End(xlUp).Row
par
Range("B" & rows.count).End(xlUp).Row
Amicalement
Bonsoir,
Bonsoir, Dan
Dans ton code, cette ligne est de trop :
If Not Com Is Nothing Then
Ainsi que le "End if" associé...
Tu peux les supprimer, car si tu n'as pas rempli les 2 conditions, rien ne va se passer...
Tu ne peux pas tester la valeur de "Com" ainsi, ce n'est pas une déclaration...
Si tu veux vraiment tester cette valeur, remplace plutôt par "If Com > 1" par exemple.
Bonne soirée