IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Affichage conditionnel dans une textbox


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Stagiaire
    Inscrit en
    Mars 2018
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Stagiaire

    Informations forums :
    Inscription : Mars 2018
    Messages : 71
    Par défaut Affichage conditionnel dans une textbox
    Bonjour,
    Je réalise actuellement une petite gmao..
    Sur celle ci on choisit qui de l'opérateur ou de la maintenance doit effectuer l action de maintenance via deux boutons optionbutton puis la semaine et les actions s'affichent.
    Le soucis c'est que lorsque je sélectionne la maintenance et le numéro de la semaine toute ma plage range est affichée, sans tenir compte des " , " et des " : " mais ça fonctionne correctement lorsque que choisis << operateur >> et non << maintenance >>... Quelqu'un aurait une idée d'où peut provenir le problème (à part de moi aha)?
    Voici le code qui gère cette partie là :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
     
     
    Public Sub ComboBox1_Change()
     
    '1iere semaine du mois
     
    TextBox8.Text = ""
    TextBox9.Text = ""
    TextBox10.Text = ""
    TextBox11.Text = ""
    Set sh = Sheets("Feuil1")
     
    If OPERATEUR = True And MAINTENANCE = False And (Me.ComboBox1.Text = "1" Or Me.ComboBox1.Text = "5" Or Me.ComboBox1.Text = "9" Or Me.ComboBox1.Text = "13" Or Me.ComboBox1.Text = "17" Or Me.ComboBox1.Text = "21" Or Me.ComboBox1.Text = "25" Or Me.ComboBox1.Text = "29" Or Me.ComboBox1.Text = "33" Or Me.ComboBox1.Text = "37" Or Me.ComboBox1.Text = "41" Or Me.ComboBox1.Text = "45" Or Me.ComboBox1.Text = "49") Then
     
    Sheets("Feuil1").Activate
     
        TextBox8.MultiLine = True
        Union(Range("B3"), Range("B4:B7"), Range("B10:B11")).Select
        Selection.Copy
        TextBox8.Paste
     
     
        TextBox9.MultiLine = True
        Union(Range("C3"), Range("C4:C7"), Range("C10:C11")).Select
        Selection.Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
        Union(Range("D3"), Range("D4:D7"), Range("D10:D11")).Select
        Selection.Copy
        TextBox10.Paste
     
    End If
     
     
    If OPERATEUR = False And MAINTENANCE = True And (Me.ComboBox1.Text = "1" Or Me.ComboBox1.Text = "5" Or Me.ComboBox1.Text = "9" Or Me.ComboBox1.Text = "13" Or Me.ComboBox1.Text = "17" Or Me.ComboBox1.Text = "21" Or Me.ComboBox1.Text = "25" Or Me.ComboBox1.Text = "29" Or Me.ComboBox1.Text = "33" Or Me.ComboBox1.Text = "37" Or Me.ComboBox1.Text = "41" Or Me.ComboBox1.Text = "45" Or Me.ComboBox1.Text = "49") Then
     
    Sheets("Feuil1").Activate
     
        TextBox8.MultiLine = True
        Union(Range("B2"), Range("B8:B9"), Range("B13"), Range("B15:B16")).Select
        Selection.Copy
        TextBox8.Paste
     
        TextBox9.MultiLine = True
        Union(Range("C2"), Range("C8:C9"), Range("C13"), Range("C15"), Range("C16")).Select
        Selection.Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
        Union(Range("D2"), Range("D8:D9"), Range("D13"), Range("D15"), Range("D16")).Select
        Selection.Copy
        TextBox10.Paste
    End If
     
    '2 ième semaine du mois
    Set sh = Sheets("Feuil1")
    If OPERATEUR = True And MAINTENANCE = False And (ComboBox1.Value = "2" Or ComboBox1.Text = "6" Or ComboBox1.Text = "10" Or ComboBox1.Text = "14" Or Me.ComboBox1.Text = "18" Or Me.ComboBox1.Text = "22" Or Me.ComboBox1.Text = "26" Or Me.ComboBox1.Text = "30" Or Me.ComboBox1.Text = "34" Or Me.ComboBox1.Text = "38" Or Me.ComboBox1.Text = "42" Or Me.ComboBox1.Text = "46" Or Me.ComboBox1.Text = "50") Then
     
    Sheets("Feuil1").Activate
     
        TextBox8.MultiLine = True
        Union(Range("B18:B21"), Range("B26:B26")).Select
        Selection.Copy
        TextBox8.Paste
     
        TextBox9.MultiLine = True
       Union(Range("C18:C21"), Range("C26:C26")).Select
       Selection.Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
       Union(Range("D18:D21"), Range("D26:D26")).Select
       Selection.Copy
        TextBox10.Paste
     
    End If
    Set sh = Sheets("Feuil1")
    Sheets("Feuil1").Activate
     
    If MAINTENANCE = True And OPERATEUR = False And (Me.ComboBox1.Value = "2" Or Me.ComboBox1.Text = "6" Or Me.ComboBox1.Text = "10" Or Me.ComboBox1.Text = "14" Or Me.ComboBox1.Text = "18" Or Me.ComboBox1.Text = "22" Or Me.ComboBox1.Text = "26" Or Me.ComboBox1.Text = "30" Or Me.ComboBox1.Text = "34" Or Me.ComboBox1.Text = "38" Or Me.ComboBox1.Text = "42" Or Me.ComboBox1.Text = "46" Or Me.ComboBox1.Text = "50") Then
     
    Sheets("Feuil1").Activate
     
        TextBox8.MultiLine = True
        Union(Range("B17"), Range("B22:B25")).Select
        Selection.Copy
        TextBox8.Paste
     
        TextBox9.MultiLine = True
        Union(Range("C17"), Range("C22:C25")).Select
        Selection.Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
        Union(Range("D17"), Range("D22:D25")).Select
        Selection.Copy
        TextBox10.Paste
    End If
     
    '3 ième semaine du mois
    Set sh = Sheets("Feuil1")
     
    If OPERATEUR = True And MAINTENANCE = False And (ComboBox1.Text = "3" Or Me.ComboBox1.Text = "7" Or Me.ComboBox1.Text = "11" Or Me.ComboBox1.Text = "15" Or Me.ComboBox1.Text = "19" Or Me.ComboBox1.Text = "23" Or Me.ComboBox1.Text = "27" Or Me.ComboBox1.Text = "31" Or Me.ComboBox1.Text = "35" Or Me.ComboBox1.Text = "39" Or Me.ComboBox1.Text = "43" Or Me.ComboBox1.Text = "47" Or Me.ComboBox1.Text = "51") Then
     
    Sheets("Feuil1").Activate
     
        TextBox8.MultiLine = True
       Union(Range("B28"), Range("B30"), Range("B37")).Select
        Selection.Copy
        TextBox8.Paste
     
        TextBox9.MultiLine = True
        Union(Range("C28"), Range("C30"), Range("C37")).Select
        Selection.Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
        Union(Range("D28"), Range("D30"), Range("D37")).Select
        Selection.Copy
        TextBox10.Paste
     
    End If
    Set sh = Sheets("Feuil1")
    If MAINTENANCE = True And OPERATEUR = False And (ComboBox1.Text = "3" Or ComboBox1.Text = "7" Or Me.ComboBox1.Text = "11" Or Me.ComboBox1.Text = "15" Or Me.ComboBox1.Text = "19" Or Me.ComboBox1.Text = "23" Or Me.ComboBox1.Text = "27" Or Me.ComboBox1.Text = "31" Or Me.ComboBox1.Text = "35" Or Me.ComboBox1.Text = "39" Or Me.ComboBox1.Text = "43" Or Me.ComboBox1.Text = "47" Or Me.ComboBox1.Text = "51") Then
     
    Sheets("Feuil1").Activate
     
        TextBox8.MultiLine = True
        Union(Range("B27"), Range("B29"), Range("B31:B36"), Range("B38")).Select
        Selection.Copy
        TextBox8.Paste
     
        TextBox9.MultiLine = True
        Union(Range("C27"), Range("C29"), Range("C31:C36"), Range("C38")).Select
        Selection.Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
        Union(Range("D27"), Range("D29"), Range("D31:D36"), Range("D38")).Select
        Selection.Copy
        TextBox10.Paste
     
    End If
     
    '4 ième semaine du mois
    Set sh = Sheets("Feuil1")
    If OPERATEUR = True And MAINTENANCE = False And (ComboBox1.Text = "4" Or Me.ComboBox1.Text = "8" Or Me.ComboBox1.Text = "12" Or Me.ComboBox1.Text = "16" Or Me.ComboBox1.Text = "20" Or Me.ComboBox1.Text = "24" Or Me.ComboBox1.Text = "28" Or Me.ComboBox1.Text = "32" Or Me.ComboBox1.Text = "36" Or Me.ComboBox1.Text = "40" Or Me.ComboBox1.Text = "44" Or Me.ComboBox1.Text = "48" Or Me.ComboBox1.Text = "52") Then
     
    Sheets("Feuil1").Activate
     
        TextBox8.MultiLine = True
        Range("B40,B42,B43,B44,B48,B49").Copy
        Me.TextBox8.Paste
     
        TextBox9.MultiLine = True
        Range("C40,C42,C43,C44,C48,C49").Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
       Range("D40,D42,D43,D44, D48,D49").Copy
        TextBox10.Paste
     
    End If
    Set sh = Sheets("Feuil1")
    If MAINTENANCE = True And OPERATEUR = False And (Me.ComboBox1.Text = "4" Or Me.ComboBox1.Text = "8" Or Me.ComboBox1.Text = "12" Or Me.ComboBox1.Text = "16" Or Me.ComboBox1.Text = "20" Or Me.ComboBox1.Text = "24" Or Me.ComboBox1.Text = "28" Or Me.ComboBox1.Text = "32" Or Me.ComboBox1.Text = "36" Or Me.ComboBox1.Text = "40" Or Me.ComboBox1.Text = "44" Or Me.ComboBox1.Text = "48" Or Me.ComboBox1.Text = "52") Then
     
    Sheets("Feuil1").Activate
     
        Me.TextBox8.MultiLine = True
        Union(Range("B39"), Range("B41"), Range("B45:B47"), Range("B50:B51")).Select
        Selection.Copy
        TextBox8.Paste
     
        TextBox9.MultiLine = True
        Union(Range("C39"), Range("C41"), Range("C45:C47"), Range("C50:C51")).Select
        Selection.Copy
        TextBox9.Paste
     
        TextBox10.MultiLine = True
        Union(Range("D39"), Range("D41"), Range("D45:D47"), Range("D50:D51")).Select
        Selection.Copy
        TextBox10.Paste
    End If
    Merci d'avoir prit le temps de lire mon message.

  2. #2
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    re
    operateur et maintenance sont ses option button ou variables ????
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    If OPERATEUR = True And MAINTENANCE = False Then
        Select Case Me.ComboBox1.Text: Case 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49: ok = True: End Select
        If ok = True Then
            Sheets("Feuil1").Activate
            TextBox8.MultiLine = True
            Union(Range("B3"), Range("B4:B7"), Range("B10:B11")).Select
            Selection.Copy
            TextBox8.Paste
     
            TextBox9.MultiLine = True
            Union(Range("C3"), Range("C4:C7"), Range("C10:C11")).Select
            Selection.Copy
            TextBox9.Paste
            TextBox10.MultiLine = True
            Union(Range("D3"), Range("D4:D7"), Range("D10:D11")).Select
            Selection.Copy
            TextBox10.Paste
        End If
    End If
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  3. #3
    Membre confirmé
    Homme Profil pro
    Stagiaire
    Inscrit en
    Mars 2018
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Stagiaire

    Informations forums :
    Inscription : Mars 2018
    Messages : 71
    Par défaut
    Citation Envoyé par patricktoulon Voir le message
    re
    operateur et maintenance sont ses option button ou variables ????
    Ce sont des optionbutton ^^

  4. #4
    Inactif  

    Homme Profil pro
    cuisiniste
    Inscrit en
    Avril 2009
    Messages
    15 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : cuisiniste
    Secteur : Bâtiment

    Informations forums :
    Inscription : Avril 2009
    Messages : 15 374
    Billets dans le blog
    8
    Par défaut re
    donc
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If OPERATEUR .value= True And MAINTENANCE.value = False Then
    voir si il sont du meme groupe (d'origine) ou par toi pas la peine de tester les deux car quant l'un deviend true l'autre deviend false
    mes fichiers dans les contributions:
    mail avec CDO en vba et mail avec CDO en vbs dans un HTA
    survol des bouton dans userform
    prendre un cliché d'un range

    si ton problème est résolu n'oublie pas de pointer : : ça peut servir aux autres
    et n'oublie pas de voter

  5. #5
    Membre confirmé
    Homme Profil pro
    Stagiaire
    Inscrit en
    Mars 2018
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Stagiaire

    Informations forums :
    Inscription : Mars 2018
    Messages : 71
    Par défaut
    Citation Envoyé par patricktoulon Voir le message
    donc
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If OPERATEUR .value= True And MAINTENANCE.value = False Then
    voir si il sont du meme groupe (d'origine) ou par toi pas la peine de tester les deux car quant l'un deviend true l'autre deviend false
    J'essaye ça de suite!

  6. #6
    Membre confirmé
    Homme Profil pro
    Stagiaire
    Inscrit en
    Mars 2018
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Stagiaire

    Informations forums :
    Inscription : Mars 2018
    Messages : 71
    Par défaut
    Toujours le même soucis....

  7. #7
    Membre confirmé
    Homme Profil pro
    Stagiaire
    Inscrit en
    Mars 2018
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Stagiaire

    Informations forums :
    Inscription : Mars 2018
    Messages : 71
    Par défaut
    Citation Envoyé par patricktoulon Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    If OPERATEUR = True And MAINTENANCE = False Then
        Select Case Me.ComboBox1.Text: Case 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49: ok = True: End Select
        If ok = True Then
            Sheets("Feuil1").Activate
            TextBox8.MultiLine = True
            Union(Range("B3"), Range("B4:B7"), Range("B10:B11")).Select
            Selection.Copy
            TextBox8.Paste
     
            TextBox9.MultiLine = True
            Union(Range("C3"), Range("C4:C7"), Range("C10:C11")).Select
            Selection.Copy
            TextBox9.Paste
            TextBox10.MultiLine = True
            Union(Range("D3"), Range("D4:D7"), Range("D10:D11")).Select
            Selection.Copy
            TextBox10.Paste
        End If
    End If
    Ce code fonctionne parfaitement bien mais lorsque je l'applique a l'optionbutton << maintenance >> ça ne fonctionne plus et m'affiche encore toute la plage sans prendre en compte les séparations dans Range... :/

Discussions similaires

  1. Affichage conditionnel dans une vue SQL
    Par adn56 dans le forum SQLite
    Réponses: 31
    Dernier message: 09/10/2015, 19h53
  2. Réponses: 3
    Dernier message: 20/09/2008, 15h32
  3. affichage de text dans une textbox
    Par geriler dans le forum Windows Forms
    Réponses: 2
    Dernier message: 14/02/2008, 16h22
  4. "Affichage conditionnel" dans une page JSF
    Par Niniz dans le forum JSF
    Réponses: 2
    Dernier message: 19/07/2007, 12h14
  5. Affichage dans une textbox
    Par philo71 dans le forum MFC
    Réponses: 25
    Dernier message: 30/01/2006, 09h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo