Effacer coche de mes checkboxs

Private Sub DisableCheckBoxes11()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets("tranche 9")

    Dim chkBox95 As Object
    Dim chkBox96 As Object
    Dim chkBox97 As Object
    Dim chkBox98 As Object
    Dim chkBox99 As Object
    Dim chkBox100 As Object
    Dim chkBox101 As Object
    Dim chkBox84 As Object
    Dim chkBox86 As Object
    Dim chkBox87 As Object
    Dim chkBox88 As Object
    Dim chkBox89 As Object
    Dim chkBox90 As Object
    Dim chkBox91 As Object

    Set chkBox95 = ws.OLEObjects("CheckBox95").Object
    Set chkBox96 = ws.OLEObjects("CheckBox96").Object
    Set chkBox97 = ws.OLEObjects("CheckBox97").Object
    Set chkBox98 = ws.OLEObjects("CheckBox98").Object
    Set chkBox99 = ws.OLEObjects("CheckBox99").Object
    Set chkBox100 = ws.OLEObjects("CheckBox100").Object
    Set chkBox101 = ws.OLEObjects("CheckBox101").Object
    Set chkBox84 = ws.OLEObjects("CheckBox84").Object
    Set chkBox86 = ws.OLEObjects("CheckBox86").Object
    Set chkBox87 = ws.OLEObjects("CheckBox87").Object
    Set chkBox88 = ws.OLEObjects("CheckBox88").Object
    Set chkBox89 = ws.OLEObjects("CheckBox89").Object
    Set chkBox90 = ws.OLEObjects("CheckBox90").Object
    Set chkBox91 = ws.OLEObjects("CheckBox91").Object

    If chkBox84.value = True Then
        chkBox86.Enabled = False
        chkBox87.Enabled = False
        chkBox88.Enabled = False
        chkBox89.Enabled = False
        chkBox90.Enabled = False
        chkBox91.Enabled = False
        chkBox95.Enabled = False
        chkBox96.Enabled = False
        chkBox97.Enabled = False
        chkBox98.Enabled = False
        chkBox99.Enabled = False
        chkBox100.Enabled = False
        chkBox101.Enabled = False
    ElseIf chkBox99.value = True Or chkBox100.value = True Or chkBox101.value = True Then
        chkBox86.Enabled = False
        chkBox87.Enabled = False
        chkBox88.Enabled = False
        chkBox89.Enabled = False
        chkBox90.Enabled = False
        chkBox91.Enabled = False
        chkBox95.Enabled = False
        chkBox96.Enabled = False
        chkBox97.Enabled = False
        chkBox98.Enabled = False
        chkBox84.Enabled = False
    ElseIf chkBox95.value = True Or chkBox96.value = True Or chkBox97.value = True Or chkBox98.value = True Then
        chkBox86.Enabled = False
        chkBox87.Enabled = False
        chkBox88.Enabled = False
        chkBox89.Enabled = False
        chkBox90.Enabled = False
        chkBox91.Enabled = False
        chkBox84.Enabled = False
        chkBox99.Enabled = False
        chkBox100.Enabled = False
        chkBox101.Enabled = False
    ElseIf chkBox86.value = True Or chkBox87.value = True Or chkBox88.value = True Or chkBox89.value = True Or chkBox90.value = True Or chkBox91.value = True Then
        chkBox84.Enabled = False
        chkBox95.Enabled = False
        chkBox96.Enabled = False
        chkBox97.Enabled = False
        chkBox98.Enabled = False
        chkBox99.Enabled = False
        chkBox100.Enabled = False
        chkBox101.Enabled = False
    Else
        chkBox84.Enabled = True
        chkBox86.Enabled = True
        chkBox87.Enabled = True
        chkBox88.Enabled = True
        chkBox89.Enabled = True
        chkBox90.Enabled = True
        chkBox95.Enabled = True
        chkBox96.Enabled = True
        chkBox97.Enabled = True
        chkBox98.Enabled = True
        chkBox99.Enabled = True
        chkBox100.Enabled = True
        chkBox101.Enabled = True
        chkBox91.Enabled = True
    End If

    Dim chk As OLEObject
    Dim checkBoxNames As Variant
    checkBoxNames = Array("CheckBox84", "CheckBox86", "CheckBox87", "CheckBox88", "CheckBox89", "CheckBox90", "CheckBox91", "CheckBox95", "CheckBox96", "CheckBox97", "CheckBox98", "CheckBox99", "CheckBox100", "CheckBox101")

    For Each chk In ws.OLEObjects
        If TypeName(chk.Object) = "CheckBox" Then
            If IsInArray(chk.Name, checkBoxNames) Then
                chk.Object.Enabled = False
            End If
        End If
    Next chk
End Sub

Private Sub UpdateLabelAppearance4()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets("tranche 9")

    Dim chkBox95 As Object
    Dim chkBox96 As Object
    Dim chkBox97 As Object
    Dim chkBox98 As Object
    Dim chkBox99 As Object
    Dim chkBox100 As Object
    Dim chkBox101 As Object
    Dim chkBox84 As Object
    Dim chkBox86 As Object
    Dim chkBox87 As Object
    Dim chkBox88 As Object
    Dim chkBox89 As Object
    Dim chkBox90 As Object
    Dim chkBox91 As Object
    Dim lbl31 As Object
    Dim lbl32 As Object
    Dim lbl30 As Object

    Set chkBox95 = ws.OLEObjects("CheckBox95").Object
    Set chkBox96 = ws.OLEObjects("CheckBox96").Object
    Set chkBox97 = ws.OLEObjects("CheckBox97").Object
    Set chkBox98 = ws.OLEObjects("CheckBox98").Object
    Set chkBox99 = ws.OLEObjects("CheckBox99").Object
    Set chkBox100 = ws.OLEObjects("CheckBox100").Object
    Set chkBox101 = ws.OLEObjects("CheckBox101").Object
    Set chkBox84 = ws.OLEObjects("CheckBox84").Object
    Set chkBox86 = ws.OLEObjects("CheckBox86").Object
    Set chkBox87 = ws.OLEObjects("CheckBox87").Object
    Set chkBox88 = ws.OLEObjects("CheckBox88").Object
    Set chkBox89 = ws.OLEObjects("CheckBox89").Object
    Set chkBox90 = ws.OLEObjects("CheckBox90").Object
    Set chkBox91 = ws.OLEObjects("CheckBox91").Object
    Set lbl31 = ws.OLEObjects("Label31").Object
    Set lbl32 = ws.OLEObjects("Label32").Object
    Set lbl30 = ws.OLEObjects("Label30").Object

 ' Mise à jour de l'apparence de Label31
    If chkBox95.value = False And chkBox96.value = False And chkBox97.value = False And chkBox98.value = False Then
        lbl31.ForeColor = RGB(105, 105, 105) ' Couleur par défaut (noir)
        lbl31.Font.Strikethrough = True ' Pas de texte rayé
        lbl31.BorderStyle = fmBorderStyleNone ' Pas d'encadré
        lbl31.Font.Strikethrough = True ' Pas de texte rayé

    Else
        lbl31.ForeColor = RGB(0, 0, 0) ' NOIR
        lbl31.Font.Strikethrough = False ' Texte NON rayé
        lbl31.BorderStyle = fmBorderStyleSingle ' Pas d'encadré
        lbl31.BackStyle = fmBackStyleOpaque ' Pas d'encadré
        lbl31.Font.Strikethrough = False
    End If

    ' Mise à jour de l'apparence de Labe30

        If chkBox86.value = False And chkBox87.value = False And chkBox88.value = False And chkBox89.value = False And chkBox90.value = False And chkBox91.value = False Then
        lbl30.ForeColor = RGB(105, 105, 105) ' Couleur par défaut (noir)
        lbl30.Font.Strikethrough = True ' Pas de texte rayé
        lbl30.BorderStyle = fmBorderStyleNone ' Pas d'encadré
        lbl30.Font.Strikethrough = True ' Pas de texte rayé

    Else
        lbl30.ForeColor = RGB(0, 0, 0) ' NOIR
        lbl30.Font.Strikethrough = False ' Texte NON rayé
        lbl30.BorderStyle = fmBorderStyleSingle ' Pas d'encadré
        lbl30.BackStyle = fmBackStyleOpaque ' Pas d'encadré
        lbl30.Font.Strikethrough = False

    End If

    ' Mise à jour de l'apparence de LabeL32
    If chkBox99.value = False And chkBox100.value = False And chkBox101.value = False Then
        lbl32.ForeColor = RGB(105, 105, 105) ' Couleur par défaut (noir)
        lbl32.Font.Strikethrough = True ' Pas de texte rayé
        lbl32.BorderStyle = fmBorderStyleNone ' Pas d'encadré
        lbl32.Font.Strikethrough = True ' Pas de texte rayé
    Else
        lbl32.ForeColor = RGB(0, 0, 0) ' NOIR
        lbl32.Font.Strikethrough = False ' Texte rayé
        lbl32.BorderStyle = fmBorderStyleSingle ' Pas d'encadré
        lbl32.BackStyle = fmBackStyleOpaque ' Pas d'encadré
        lbl32.Font.Strikethrough = False

    End If
End Sub
Private Sub CommandButton2_Click()
    Dim ws As Worksheet
    Dim cb As OLEObject
    Dim response As VbMsgBoxResult

    ' Référence à la feuille "Tranche 9"
    Set ws = ThisWorkbook.Sheets("Tranche 9")

    ' Demande de confirmation
    response = MsgBox("Voulez-vous effacer toutes les coches ?", vbYesNo + vbQuestion, "Confirmation")

    If response = vbYes Then
        ' Parcourt toutes les CheckBox ActiveX de la feuille et les décoche
        For Each cb In ws.OLEObjects
            If TypeName(cb.Object) = "CheckBox" Then
                cb.Object.value = False
            End If
        Next cb
        MsgBox "Toutes les coches ont été effacées.", vbInformation, "Terminé"
    Else
        MsgBox "Aucune coche n'a été effacée.", vbInformation, "Annulé"
    End If
End Sub

bonjour,

j'aimerai effacer toutes les coches de mes checkboxs (en activix) d'une feuille excel à partir d'un bouton mais rien ne se passe voici une partie de mon code , merci de votre aide !

Bonjour,

Tous ces CheckBox dans une feuille : C'est toujours un erreur de conception !

A+

Rechercher des sujets similaires à "effacer coche mes checkboxs"