OVH Cloud OVH Cloud

incorporer une formule mais ou?

1 réponse
Avatar
debutant
bonsoir
c'est encore moi

voila dans mon userform2 j'ais ceci:

Private Sub CheckBox1_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("i" & Ligne).Value = "X"
CheckBox1.Value = True

End Sub


Private Sub CheckBox2_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("j" & Ligne).Value = "X"
CheckBox2.Value = True
End Sub

Private Sub CheckBox3_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("k" & Ligne).Value = "X"
CheckBox3.Value = True

End Sub

Private Sub CheckBox4_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("l" & Ligne).Value = "X"
CheckBox4.Value = True

End Sub

et je souhaiterais y incorporer ceci:
If [Feuil1!i3] = "X" And [Feuil1!j3] = "X" And [Feuil1!k3] = "X" And
[Feuil1!l3] = "X" Then [feuil1!A3].copy [feuil2!A3] Else MsgBox " Toutes les
cases ne sont pas cochées"

le but est de copier une cellule de la feuille 1 dans la feuille 2 si les 4
checkbox sont cocher.

mais je ne sais pas comment faire pouvez vous m'aider merci d'avance a toute
les bonne ames

1 réponse

Avatar
lSteph
Bonjour,
insère un module de classe que tu nommes ClassChk
(sélectionne le dans l'explorateur de projet et affiche la fenêtre
propriétés)
sélectionne ensuite dans ton userform2
et mets tes checkbok de 1 à 4 respectivement avec en caption i,j,k,l

'''*****dans le module de classe
Public WithEvents MonChk As MSForms.CheckBox
Private Sub MonChk_Click()

Dim Ligne As Long
Ligne = Application.Match(UserForm2.ComboBox1, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range(MonChk.Caption & Ligne).Value = "X"
MonChk.Value = True
With UserForm2
If .CheckBox1 And .CheckBox2 And .CheckBox3 And _
.CheckBox4 Then [feuil1!A3].Copy [feuil2!A3]
End With
End Sub
'''*****dans le code de userform2
Private MesChk() As New ClassChk
Private Sub UserForm_Initialize()
Dim clt As Control, I&
For Each clt In Me.Controls
If TypeName(clt) = "CheckBox" Then

ReDim Preserve MesChk(0 To I)
Set MesChk(I).MonChk = clt
I = I + 1
End If
Next clt
End Sub
Private Sub UserForm_Terminate()
Dim I&
For I = 0& To UBound(MesChk)
Set MesChk(I) = Nothing
Next I
End Sub
'''*********************

'lSteph


"debutant" a écrit dans le message de news:
43ff63dc$0$166$
bonsoir
c'est encore moi

voila dans mon userform2 j'ais ceci:

Private Sub CheckBox1_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("i" & Ligne).Value = "X"
CheckBox1.Value = True
if CheckBox1 and CheckBox2 and CheckBox3 and CheckBox4 then [feuil1!A3].copy

[feuil2!A3]


End Sub


Private Sub CheckBox2_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("j" & Ligne).Value = "X"
CheckBox2.Value = True
End Sub

Private Sub CheckBox3_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("k" & Ligne).Value = "X"
CheckBox3.Value = True

End Sub

Private Sub CheckBox4_Click()
Dim Ligne As Long
Ligne = Application.Match(ComboBox1.Value, Range("b1", _
Range("b65536").End(xlUp)), 0)
Range("l" & Ligne).Value = "X"
CheckBox4.Value = True

End Sub

et je souhaiterais y incorporer ceci:
If [Feuil1!i3] = "X" And [Feuil1!j3] = "X" And [Feuil1!k3] = "X" And
[Feuil1!l3] = "X" Then [feuil1!A3].copy [feuil2!A3] Else MsgBox " Toutes
les
cases ne sont pas cochées"

le but est de copier une cellule de la feuille 1 dans la feuille 2 si les
4
checkbox sont cocher.

mais je ne sais pas comment faire pouvez vous m'aider merci d'avance a
toute
les bonne ames