Probleme au niveau d'une condition if
Résolu
rr120
-
rr120 -
rr120 -
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
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
A voir également:
- Probleme au niveau d'une condition if
- Clé mise a niveau windows 7 - Guide
- Excel cellule couleur si condition texte - Guide
- Mise a niveau windows 7 vers 10 - Accueil - Mise à jour
- Excel a rencontré un problème au niveau d'une ou de plusieurs références de formules - Forum Bureautique
- Excel a rencontré un problème au niveau d'une ou de plusieurs références - Forum Excel