Probleme excel vba

titepestounette Messages postés 23 Date d'inscription   Statut Membre Dernière intervention   -  
Bidouilleu_R Messages postés 1181 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

Voila je cherche juste à savoir pourquoi cela ne fonctionne pas

Private Sub CommandButton1_Click()
Dim str As Variant
If CheckBox1 = True Then
str = Range("A1").Value
CheckBox1 = str
else if (checkbox1 = false and checkbox2 = true) then
str = Range("A1").Value
CheckBox2 = str
else if (checkbox1 = true and checkbox2 = true) then
str = Range("A1").Value
CheckBox1 = str
str = Range("A2").Value
CheckBox2 = str
End If
End Sub

merci

titepestounette
A voir également:

4 réponses

pou pouille Messages postés 207 Date d'inscription   Statut Membre Dernière intervention   31
 
bonjour,
il manque des End If ... ensuite j'ai pas encore tester le code
Private Sub CommandButton1_Click()
Dim str As Variant
If checkbox1 = True Then
    str = Range("A1").Value
    checkbox1 = str
Else
    If (checkbox1 = False And checkbox2 = True) Then
        str = Range("A1").Value
        checkbox2 = str
    Else
        If (checkbox1 = True And checkbox2 = True) Then
            str = Range("A1").Value
            checkbox1 = str
            str = Range("A2").Value
            checkbox2 = str
        End If
    End If
End If
End Sub
0
Anauel
 
Remplace "else if" par "elseif" , il n'y a pas d'espace entre les deux. Pas besoin d'avoir autant de if / end if comme la réponse d'avant.
0
eriiic Messages postés 24603 Date d'inscription   Statut Contributeur Dernière intervention   7 275
 
Bonsoir,

Et il y a une erreur de structure :
If CheckBox1 = True Then
...
elseif (checkbox1 = true and checkbox2 = true) then
...

Si le 1er test est positif tu ne passeras jamais dans le 2nd

eric
0
Bidouilleu_R Messages postés 1181 Date d'inscription   Statut Membre Dernière intervention   295
 
et je suppose que range("A1") contient vrai ou faux sinon le checbox sera null
ce qui n'arrange rien.
Explique ce que tu veux faire... et tu auras de bons conseils
0