Condition si plusieurs cases à cocher sont cochées
Résolu/Fermé
bassmart
Messages postés
277
Date d'inscription
jeudi 19 février 2015
Statut
Membre
Dernière intervention
30 août 2022
-
19 mai 2015 à 15:19
bassmart Messages postés 277 Date d'inscription jeudi 19 février 2015 Statut Membre Dernière intervention 30 août 2022 - 19 mai 2015 à 16:44
bassmart Messages postés 277 Date d'inscription jeudi 19 février 2015 Statut Membre Dernière intervention 30 août 2022 - 19 mai 2015 à 16:44
A voir également:
- Condition si plusieurs cases à cocher sont cochées
- Comment cocher une case sur word ✓ - Forum Word
- Recherchev avec condition si ✓ - Forum Excel
- Agrandir case à cocher excel ✓ - Forum Programmation
- Excel condition couleur - Guide
- Supprimer case à cocher excel ✓ - Forum Excel
1 réponse
pijaku
Messages postés
12263
Date d'inscription
jeudi 15 mai 2008
Statut
Modérateur
Dernière intervention
15 mars 2023
2 712
19 mai 2015 à 15:42
19 mai 2015 à 15:42
Bonjour,
Pour faire simple, en reprenant votre code, il suffit d'utiliser des If/End If en lieu et place des If/ElseIf/EndIf :
Mais on peut également faire beaucoup plus court comme code...
A voir si intéressé.
Pour faire simple, en reprenant votre code, il suffit d'utiliser des If/End If en lieu et place des If/ElseIf/EndIf :
Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
wns = "Coordonnées"
zone = "ZoneCoord"
ZoneDate = "ZoneDateCoord"
End If
If CheckBox2.Value = True Then
wns = "CPTU"
zone = "ZoneCPTU"
ZoneDate = "ZoneDateCPTU"
End If
If CheckBox3.Value = True Then
wns = "Piézomètres"
zone = "ZonePiézo"
ZoneDate = "ZoneDatePiézo"
End If
If CheckBox4.Value = True Then
wns = "Inclinomètres"
zone = "ZoneInclino"
ZoneDate = "ZoneDateInclino"
End If
If CheckBox5.Value = True Then
wns = "Suivi Implantation"
zone = "ZoneImplant"
ZoneDate = "ZoneDateImplant"
End If
If CheckBox6.Value = True Then
wns = "FORAGE"
zone = "ZoneForage"
ZoneDate = "ZoneDateForage"
End If
If ComboBox1 = "" Then
MsgBox "Vous devez inscrire votre nom!", vbCritical, "NOM"
Exit Sub
End If
If wns = "" Then
MsgBox "Vous-n'avez pas sélectionnez de feuilles!", vbCritical, "Feuilles"
Exit Sub
End If
Sheets(wns).Shapes(zone).TextFrame.Characters.Text = ComboBox1.Value
Sheets(wns).Shapes(ZoneDate).TextFrame.Characters.Text = Label3
UserForm5.Hide
End Sub
Mais on peut également faire beaucoup plus court comme code...
A voir si intéressé.
19 mai 2015 à 15:56
Option Explicit Const FEUILLES As String = "Coordonnées;CPTU;Piézomètres;Inclinomètres;Suivi Implantation;FORAGE" Const ZONES As String = "ZoneCoord;ZoneCPTU;ZonePiézo;ZoneInclino;ZoneImplant;ZoneForage" Const ZONESDATES As String = "ZoneDateCoord;ZoneDateCPTU;ZoneDatePiézo;ZoneDateInclino;ZoneDateImplant;ZoneDateForage" Private Sub CommandButton1_Click() Dim i As Integer 'vérification If ComboBox1 = "" Then MsgBox "Vous devez inscrire votre nom!", vbCritical, "NOM" Exit Sub End If 'insertion données For i = 1 To 6 If Me.Controls("CheckBox" & i).Value = True Then With Sheets(Split(FEUILLES, ";")(i - 1)) .Shapes(Split(ZONES, ";")(i - 1)).TextFrame.Characters.Text = ComboBox1.Value .Shapes(Split(ZONESDATES, ";")(i - 1)).TextFrame.Characters.Text = Label3.Caption End With End If Next i Me.Hide End Sub19 mai 2015 à 16:44
J'ai utilisé ton code simplifié et ça fonctionne très bien!