Probleme excel vba

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. 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
    1. Contributeur
      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
      1. 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
        1. 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