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 :

Modification d'affichage d'un label dans une feuille


Sujet :

Macros et VBA Excel

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 166
    Points : 94
    Points
    94
    Par défaut Modification d'affichage d'un label dans une feuille
    Bonjour,

    J'ai un label dans une feuille avec une inscription dans Caption

    En cliquant sur un bouton pour exécuter un programme, je veux changer le texte du label par un autre message. A la fin du programme, je veux revenir au message précédent. (voir lignes 22 à 25 et 335 à 356)

    Le problème est que cette modification ne s'affiche pas pendant l'exécution du programme.

    Lorsque je met un point d'arrêt dans le programme je vois bien cette modification
    Je ne comprends pas !

    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
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    Private Sub CommandButton5_Click()
    '
    Dim R As Range
    Dim L As Long
    Dim Tb
    Dim Rchercher As String
    Dim Itb As Long
    Dim trouve As Boolean
    Dim Serie As Integer
    Dim RefFab As Integer
    Dim Com As Integer
    Dim Mag As String
    Dim NLigne As Long
    Dim TableauMagasins
    '
    'Application.Cursor = xlWait
    '
    ControlRech = 0
    ListBox11.Clear
    '
     
    NomLabel90 = Principal.Label90.Caption
     
    Principal.Label90.Caption = "Recherche en cours - Veuillez patienter ..."
    Principal.Label90.ForeColor = 255
    'color label original = -2147483630
     
    If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox6.Value = False And CheckBox7.Value = False Then
        RechOption = 0
    End If
    '
    Select Case RechOption
    '
    Case 1 ' recherche sur le numéro de série
     
        If Trim("" & TextBox1) = "" Then Exit Sub
            Tb = Split(TextBox1 & " ", " ")
            Set R = Workbooks("Stock.xls").Sheets("Stock").UsedRange
            ReDim tb2(Itb)
            Itb = -1
            If OU = 1 Then
                For L = 2 To R.Rows.Count
                trouve = False
                    For I = 0 To UBound(Tb)
                        trouve = True
                        If Trim("" & Tb(I)) <> "" Then
                            If InStr(1, R(L, 6), UCase(Trim("" & Tb(I)))) > 0 Then
                                Itb = Itb + 1
                                 ReDim Preserve tb2(Itb)
                                 If Trim("" & tb2(Itb)) = "" Then
                                     tb2(Itb) = L ' numéro de la ligne de l'onglet
                                 Else
                                     tb2(Itb) = L 'numéro de la ligne de l'onglet
                                 End If
                            End If
                        End If
                    Next I
                Next L
            End If
        If ET = 1 Then
          For L = 2 To R.Rows.Count
            P = 0
            trouve = False
            For I = 0 To UBound(Tb)
                trouve = True
                If Trim("" & Tb(I)) <> "" Then
                    If InStr(1, R(L, 6), UCase(Trim("" & Tb(I)))) > 0 Then
                        P = P + 1
                    End If
                    If P = UBound(Tb) Then
                       Itb = Itb + 1
                            ReDim Preserve tb2(Itb)
                            If Trim("" & tb2(Itb)) = "" Then
                                tb2(Itb) = L ' numéro de la ligne de l'onglet
                            Else
                                tb2(Itb) = L 'numéro de la ligne de l'onglet
                            End If
                    End If
                 End If
            Next I
          Next L
        End If
        Principal.ListBox11.ColumnCount = 4
        Z = 0
        Erase MyArrayRecherche
        ReDim MyArrayRecherche(UBound(tb2) + 1, 3)
        MyArrayRecherche(0, 1) = "N° Série"
        MyArrayRecherche(0, 2) = "Article"
        MyArrayRecherche(0, 3) = "Description article"
        For x = 0 To UBound(tb2)
            If tb2(x) <> "" Then
                Z = Z + 1
                MyArrayRecherche(Z, 1) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 6)
                MyArrayRecherche(Z, 2) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 1)
                MyArrayRecherche(Z, 3) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 10)
            End If
        Next x
        If tb2(0) = "" Then
            MsgBox ("Aucun résultat")
        End If
        Principal.ListBox11.Clear
        Principal.ListBox11.List() = MyArrayRecherche
        Principal.ListBox11.ColumnWidths = "10;80;80;300" ' largeur des colonnes
     
    Case 2 'Recherche sur la référence fabricant
     
        If Trim("" & TextBox1) = "" Then Exit Sub
            Tb = Split(TextBox1 & " ", " ")
            Set R = Workbooks("Revue_Referentiel.xls").Sheets("Ref fabricant").UsedRange
            ReDim tb2(Itb)
            Itb = -1
        If OU = 1 Then
            For L = 2 To R.Rows.Count
            trouve = False
                For I = 0 To UBound(Tb)
                    trouve = True
                    If Trim("" & Tb(I)) <> "" Then
                        If InStr(1, R(L, 6), UCase(Trim("" & Tb(I)))) > 0 Then
                            Itb = Itb + 1
                             ReDim Preserve tb2(Itb)
                             If Trim("" & tb2(Itb)) = "" Then
                                 tb2(Itb) = L ' numéro de la ligne de l'onglet
                             Else
                                 tb2(Itb) = L 'numéro de la ligne de l'onglet
                             End If
                        End If
                    End If
                Next I
            Next L
        End If
        If ET = 1 Then
          For L = 2 To R.Rows.Count
            P = 0
            trouve = False
            For I = 0 To UBound(Tb)
                trouve = True
                If Trim("" & Tb(I)) <> "" Then
                    If InStr(1, R(L, 6), UCase(Trim("" & Tb(I)))) > 0 Then
                        P = P + 1
                    End If
                    If P = UBound(Tb) Then
                       Itb = Itb + 1
                            ReDim Preserve tb2(Itb)
                            If Trim("" & tb2(Itb)) = "" Then
                                tb2(Itb) = L ' numéro de la ligne de l'onglet
                            Else
                                tb2(Itb) = L 'numéro de la ligne de l'onglet
                            End If
                    End If
                 End If
            Next I
          Next L
        End If
        Principal.ListBox11.ColumnCount = 6
        Z = 0
        Erase MyArrayRecherche
        ReDim MyArrayRecherche(UBound(tb2) + 1, 5)
        MyArrayRecherche(0, 1) = "Référence Fabricant"
        MyArrayRecherche(0, 2) = "Nom Fabricant"
        MyArrayRecherche(0, 3) = "Article"
        MyArrayRecherche(0, 4) = "Description article"
        MyArrayRecherche(0, 5) = "Date de Modifiation"
        For x = 0 To UBound(tb2)
            If tb2(x) <> "" Then
                Z = Z + 1
                MyArrayRecherche(Z, 1) = Workbooks("Revue_Referentiel.xls").Sheets("Ref Fabricant").Cells(tb2(x), 6)
                MyArrayRecherche(Z, 2) = Workbooks("Revue_Referentiel.xls").Sheets("Ref Fabricant").Cells(tb2(x), 3)
                MyArrayRecherche(Z, 3) = Workbooks("Revue_Referentiel.xls").Sheets("Ref Fabricant").Cells(tb2(x), 1)
                MyArrayRecherche(Z, 4) = Workbooks("Revue_Referentiel.xls").Sheets("Ref Fabricant").Cells(tb2(x), 2)
                MyArrayRecherche(Z, 5) = Workbooks("Revue_Referentiel.xls").Sheets("Ref Fabricant").Cells(tb2(x), 7)
            End If
        Next x
        If tb2(0) = "" Then
            MsgBox ("Aucun résultat")
        End If
        Principal.ListBox11.Clear
        Principal.ListBox11.List() = MyArrayRecherche
        Principal.ListBox11.ColumnWidths = "5;90;90;60;300;40" ' largeur des colonnes
     
    Case 3 'Recherche sur le projet
     
        If Trim("" & TextBox1) = "" Then Exit Sub
            Tb = Split(TextBox1 & " ", " ")
            Set R = Workbooks("Stock.xls").Sheets("Stock").UsedRange
            ReDim tb2(Itb)
            Itb = -1
        If OU = 1 Then
            For L = 2 To R.Rows.Count
            trouve = False
                For I = 0 To UBound(Tb)
                    trouve = True
                    If Trim("" & Tb(I)) <> "" Then
                        If InStr(1, R(L, 11), UCase(Trim("" & Tb(I)))) > 0 Then
                            Itb = Itb + 1
                             ReDim Preserve tb2(Itb)
                             If Trim("" & tb2(Itb)) = "" Then
                                 tb2(Itb) = L ' numéro de la ligne de l'onglet
                             Else
                                 tb2(Itb) = L 'numéro de la ligne de l'onglet
                             End If
                        End If
                    End If
                Next I
            Next L
        End If
     
        If ET = 1 Then
          For L = 2 To R.Rows.Count
            P = 0
            trouve = False
            For I = 0 To UBound(Tb)
                trouve = True
                If Trim("" & Tb(I)) <> "" Then
                    If InStr(1, R(L, 11), UCase(Trim("" & Tb(I)))) > 0 Then
                        P = P + 1
                    End If
                    If P = UBound(Tb) Then
                       Itb = Itb + 1
                            ReDim Preserve tb2(Itb)
                            If Trim("" & tb2(Itb)) = "" Then
                                tb2(Itb) = L ' numéro de la ligne de l'onglet
                            Else
                                tb2(Itb) = L 'numéro de la ligne de l'onglet
                            End If
                    End If
                 End If
            Next I
          Next L
        End If
        Principal.ListBox11.ColumnCount = 6
        Z = 0
        Erase MyArrayRecherche
        ReDim MyArrayRecherche(UBound(tb2) + 1, 5)
        MyArrayRecherche(0, 1) = "N° Projet"
        MyArrayRecherche(0, 2) = "Libellé Projet"
        MyArrayRecherche(0, 3) = "Pilote Projet"
        MyArrayRecherche(0, 4) = "Article"
        MyArrayRecherche(0, 5) = "Description article"
        For x = 0 To UBound(tb2)
            If tb2(x) <> "" Then
                Z = Z + 1
                MyArrayRecherche(Z, 1) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 11)
                MyArrayRecherche(Z, 2) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 12)
                MyArrayRecherche(Z, 3) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 13)
                MyArrayRecherche(Z, 4) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 1)
                MyArrayRecherche(Z, 5) = Workbooks("Stock.xls").Sheets("Stock").Cells(tb2(x), 10)
            End If
        Next x
        If tb2(0) = "" Then
            MsgBox ("Aucun résultat")
        End If
        Principal.ListBox11.Clear
        Principal.ListBox11.List() = MyArrayRecherche
        Principal.ListBox11.ColumnWidths = "5;70;180;100;60;300" ' largeur des colonnes
     
    Case 4 'Recherche par magasins
    '
    TextBox2 = TextBox1
    MultiPage1.Value = 11
    '
    Call CommandButton7_Click
    '
    Case 5 'Recherche par Code Articles
     
    'Beep
     
    Call CommandButton1_Click
     
     
     
    Case Else
     
        If Trim("" & TextBox1) = "" Then Exit Sub
            Tb = Split(TextBox1 & " ", " ")
            Set R = Workbooks("Revue_Referentiel.xls").Sheets("Ref").UsedRange
            ReDim tb2(Itb)
            Itb = -1
            ' Recherche sur les libellés plusieurs mots par un ET
        If OU = 1 Then
            For L = 2 To R.Rows.Count
                trouve = False
                For I = 0 To UBound(Tb)
                    trouve = True
                    If Trim("" & Tb(I)) <> "" Then
                        If InStr(1, R(L, 3), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 4), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 50), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 51), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 52), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 53), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 54), UCase(Trim("" & Tb(I)))) > 0 Then
                            Itb = Itb + 1
                             ReDim Preserve tb2(Itb)
                             If Trim("" & tb2(Itb)) = "" Then
                                 tb2(Itb) = L ' numéro de la ligne de l'onglet
                             Else
                                 tb2(Itb) = L 'numéro de la ligne de l'onglet
                             End If
                        End If
                    End If
                Next I
            Next L
        End If
        ' Recherche sur les libellés plusieurs mots par un ET
        If ET = 1 Then
          For L = 2 To R.Rows.Count
          P = 0
          trouve = False
              For I = 0 To UBound(Tb)
                trouve = True
                If Trim("" & Tb(I)) <> "" Then
                    If InStr(1, R(L, 3), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 4), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 50), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 51), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 52), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 53), UCase(Trim("" & Tb(I)))) > 0 Or InStr(1, R(L, 54), UCase(Trim("" & Tb(I)))) > 0 Then
                      P = P + 1
                    End If
                    If P = UBound(Tb) Then
                        Itb = Itb + 1
                        ReDim Preserve tb2(Itb)
                        If Trim("" & tb2(Itb)) = "" Then
                            tb2(Itb) = L ' numéro de la ligne de l'onglet
                        Else
                            tb2(Itb) = L 'numéro de la ligne de l'onglet
                        End If
                    End If
                End If
              Next I
          Next L
        End If
        Principal.ListBox11.ColumnCount = 8
        Z = 0
        Erase MyArrayRecherche
        ReDim MyArrayRecherche(UBound(tb2) + 1, 7)
        For x = 0 To UBound(tb2)
            If tb2(x) <> "" Then
                Z = Z + 1
                MyArrayRecherche(Z, 1) = Workbooks("Revue_Referentiel.xls").Sheets("Ref").Cells(tb2(x), 2)
                MyArrayRecherche(Z, 2) = Workbooks("Revue_Referentiel.xls").Sheets("Ref").Cells(tb2(x), 3)
            End If
        Next x
        If tb2(0) = "" Then
            MsgBox ("Aucun résultat")
            Exit Sub
        End If
        '
        Call Detail_Stock
        '
        MyArrayRecherche(0, 1) = "Article"
        MyArrayRecherche(0, 2) = "Description article"
        MyArrayRecherche(0, 3) = "Stock Dispo"
        MyArrayRecherche(0, 4) = "Stock Transit"
        MyArrayRecherche(0, 5) = "Stock Reserve"
        MyArrayRecherche(0, 6) = "Stock HS"
        MyArrayRecherche(0, 7) = "Stock Déploiement"
        '
        Principal.ListBox11.Clear
        Principal.ListBox11.List() = MyArrayRecherche
        Principal.ListBox11.ColumnWidths = "10;80;380;60;60;60;60;60" ' largeur des colonnes
    '
    End Select
    'Application.Cursor = XlDéfault
    '
    Principal.Label90.Caption = NomLabel90
    Principal.Label90.ForeColor = -2147483630
    '
    End Sub
    merci pour votre aide

  2. #2
    Membre confirmé
    Homme Profil pro
    Responsable des études(en disponibilité)
    Inscrit en
    Juin 2007
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Responsable des études(en disponibilité)
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 365
    Points : 631
    Points
    631
    Par défaut
    essaye en ajoutant

    au changement de valeur

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    166
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 166
    Points : 94
    Points
    94
    Par défaut
    Super cela a fonctionné

    merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Python 2.X] affichage d'un label dans une fenetre toplevel avec un randint
    Par mathmath2000 dans le forum Tkinter
    Réponses: 9
    Dernier message: 26/04/2018, 12h08
  2. [Python 2.X] affichage d'un label dans une fenetre toplevel avec un randint
    Par mathmath2000 dans le forum Général Python
    Réponses: 9
    Dernier message: 26/04/2018, 12h08
  3. Imprimer un Label dans une feuille
    Par kortobi dans le forum AWT/Swing
    Réponses: 1
    Dernier message: 20/02/2013, 09h24
  4. Réponses: 2
    Dernier message: 08/02/2012, 14h27
  5. Réponses: 2
    Dernier message: 06/04/2007, 21h37

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