Probleme excel vba

titepestounette Messages postés 24 Statut Membre -  
Bidouilleu_R Messages postés 1209 Statut Membre -
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
Configuration: Windows XP Internet Explorer 7.0

4 réponses

  1. pou pouille Messages postés 212 Statut Membre 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
  2. 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
  3. eriiic Messages postés 24581 Date d'inscription   Statut Contributeur Dernière intervention   7 281
     
    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
  4. Bidouilleu_R Messages postés 1209 Statut Membre 296
     
    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