Probleme au niveau d'une condition if

Résolu/Fermé
rr120 - 24 mai 2013 à 11:51
 rr120 - 24 mai 2013 à 12:21
Bonjour tout le monde,

je suis débutant en vba et je suis entrain de créer un userform pour remplir un tableaux, mon problème c'est que quand je sélectionne toutes les checkbox que j'ai mis sur le userform il marche nickel , mais quand je sélectionne qu'un checkbox il me renvoie la même checkbox mais 5fois (nombre de if je pense).voila mon code

Private Sub CommandButton2_Click()

Dim L As Integer
L = Sheets("Section-présentation").Range("G65536").End(xlUp).Row + 1
With Sheets("Section-présentation")
.Range("A" & L).Value = TextBox1.Value
.Range("B" & L).Value = ComboBox2.Value
.Range("C" & L).Value = TextBox3.Value

L = Sheets("Section-présentation").Range("D65536").End(xlUp).Row + 1
If CheckBox2.Value = True And .Range("D" & L).Value = "" Then
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.creationdate"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly"
.Range("G" & L).Value = "true"

Else: L = L + 1
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.creationdate"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly"
.Range("G" & L).Value = "true"

End If

L = Sheets("Section-présentation").Range("D65536").End(xlUp).Row + 1
If CheckBox3.Value = True And .Range("D" & L).Value = "" Then
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.modified"
.Range("E" & L).Value = ""

Else: L = L + 1
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.creationdate"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly"
.Range("G" & L).Value = "true"

End If

L = Sheets("Section-présentation").Range("D65536").End(xlUp).Row + 1
If CheckBox4.Value = True And .Range("D" & L).Value = "" Then
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.resolutiondate"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly" & ";hideIfEmpty"
.Range("G" & L).Value = "true" & ";true"

Else: L = L + 1
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.resolutiondate"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly"
.Range("G" & L).Value = "true"

End If

L = Sheets("Section-présentation").Range("D65536").End(xlUp).Row + 1
If CheckBox5.Value = True And .Range("D" & L).Value = "" Then
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.5"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly" & ";hideIfEmpty"
.Range("G" & L).Value = "true" & ";true"

Else: L = L + 1
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.6"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly"
.Range("G" & L).Value = "true"

End If

L = Sheets("Section-présentation").Range("D65536").End(xlUp).Row + 1
If CheckBox6.Value = True And .Range("D" & L).Value = "" Then
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.6"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly" & ";hideIfEmpty"
.Range("G" & L).Value = "true" & ";true"

Else: L = L + 1
.Range("D" & L).Value = "com.ibm.team.workitem.attribute.6"
.Range("E" & L).Value = ""
.Range("F" & L).Value = "readonly"
.Range("G" & L).Value = "true"

End If

End With
MsgBox "élement crée"
Unload UserForm1

End Sub

je vous rappel que je suis débutanten vba .merci d'avance

1 réponse

c'est bon c'est de ma faute j'ai oublier d'enlever les ELSE c'est résolue
0