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 :

Peut on créer 2 Worksheet_Change à la suite dans la même feuille


Sujet :

Macros et VBA Excel

  1. #1
    Membre averti
    Femme Profil pro
    FORMATEUR BUREAUTIQUE
    Inscrit en
    Mai 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : FORMATEUR BUREAUTIQUE

    Informations forums :
    Inscription : Mai 2010
    Messages : 21
    Par défaut Peut on créer 2 Worksheet_Change à la suite dans la même feuille
    Bjr à tous,

    J'ai créé 2 worksheet, qui marchent trés bien séparés.Peut-on en mettre 2 à la suite. (Je vous ai joint le fichier).

    La 1ère worksheet rencontre un pb, car la date du jour devrait se mettre systématiquement en colonne F, lorsque l'on sélectionne dans la colonne A un texte et en C, une date. Cette macro reprend la date du systeme, pour ensuite changer savaleur pour ne pas à une prochaine ouverture se réactualiser. Elle marche trés bien seule.

    La 2nde macro MFC sur plusieurs conditions en colonne A22:A25 (couleurs caractères du texte) marche également trés bien toute seule.

    Est-ce que cette ligne dans la 2nde worksheet ne poserait pas des pb à la 1ere :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     If Intersect(Target, Range("A22:A25")) Is Nothing Then: Exit Sub 'Supprimer pour toute la page
    Pourriez vous m'expliquer à quoi cela correspond, j'ai récupéré ces 2 macros et je les ai modifié. Je pratique depuis quelques mois, mais je suis débutante en VBA et y vais pas à pas...

    Merci de votre aide !

    Vérolyde

  2. #2
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Bonjour,

    Cette ligne sort de la procèdure si la cellule modifiée n'est pas dans la plage A22:A25
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     If Intersect(Target, Range("A22:A25")) Is Nothing Then: Exit Sub
    Pour aller plus loin il faudrait que tu postes tout le code de la procèdure

  3. #3
    Membre averti
    Femme Profil pro
    FORMATEUR BUREAUTIQUE
    Inscrit en
    Mai 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : FORMATEUR BUREAUTIQUE

    Informations forums :
    Inscription : Mai 2010
    Messages : 21
    Par défaut
    Bjr,

    Désolée, j'avais joint le fichier mais apparemment, il n'y était pas !

    Voici la procédure :

    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
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A22:A25")) Is Nothing Then: Exit Sub 'Supprimer pour toute la page
        With Target
        Select Case Target.Value
        Case Is = "A"
        .Font.ColorIndex = 3 'caractère en rouge
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CEF"
        .Font.ColorIndex = 7 'caractère en rose
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CET"
        .Font.ColorIndex = 2 'caractère en blanc
            With Selection.Interior
            .ColorIndex = 3 'fond rouge
            .Pattern = xlSolid
            End With
        Case Is = "CMAT"
        .Font.ColorIndex = 46 'caractère en orange
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CPAT"
        .Font.ColorIndex = 46 'caractère en orange
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CP"
        .Font.ColorIndex = 5 'caractère en bleu
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CP½A"
        .Font.ColorIndex = 5 'caractère en bleu
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CP½M"
        .Font.ColorIndex = 5 'caractère en bleu
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CPE"
        .Font.ColorIndex = 9 'caractère en marron
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "CSS"
        .Font.ColorIndex = 8 'caractère en turquoise
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "EMAL"
        .Font.ColorIndex = 1 'caractère en noir
            With Selection.Interior
            .ColorIndex = 7 'fond rose
            .Pattern = xlSolid
            End With
        Case Is = "EMAL½A"
        .Font.ColorIndex = 1 'caractère en noir
            With Selection.Interior
            .ColorIndex = 7 'fond rose
            .Pattern = xlSolid
            End With
        Case Is = "EMAL½M"
        .Font.ColorIndex = 1 'caractère en noir
            With Selection.Interior
            .ColorIndex = 7 'fond rose
            .Pattern = xlSolid
            End With
        Case Is = "MAL"
        .Font.ColorIndex = 1 'caractère en noir
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "MAL½A"
        .Font.ColorIndex = 1 'caractère en noir
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "MAL½M"
        .Font.ColorIndex = 1 'caractère en noir
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "RTT"
        .Font.ColorIndex = 10 'caractère en vert
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "RTT½A"
        .Font.ColorIndex = 10 'caractère en vert
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "RTT½M"
        .Font.ColorIndex = 10 'caractère en vert
            With Selection.Interior
            .ColorIndex = 2 'fond blanc
            .Pattern = xlSolid
            End With
        Case Is = "RTTE"
        .Font.ColorIndex = 2 'caractère en blanc
            With Selection.Interior
            .ColorIndex = 10 'fond vert
            .Pattern = xlSolid
            End With
        Case Is = "RTTE TRAV"
        .Font.ColorIndex = 3 'caractère en rouge
            With Selection.Interior
            .ColorIndex = 10 'fond vert
            .Pattern = xlSolid
            End With
        Case Else
        .Font.ColorIndex = xlNone
        .Interior.ColorIndex = xlNone
        End Select
        End With
    End Sub
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$C$22" Then If Not (IsEmpty(Target.Value)) Then Range("F22").Value = Now Else Range("F22").ClearContents
    If Target.Address = "$C$23" Then If Not (IsEmpty(Target.Value)) Then Range("F23").Value = Now Else Range("F23").ClearContents
    If Target.Address = "$C$24" Then If Not (IsEmpty(Target.Value)) Then Range("F24").Value = Now Else Range("F24").ClearContents
    If Target.Address = "$C$25" Then If Not (IsEmpty(Target.Value)) Then Range("F25").Value = Now Else Range("F25").ClearContents
    End Sub
    Merci de votre aide !

    Vérolyde

    Fichiers joints VBA : http://www.developpez.net/forums/d84...s-discussions/

  4. #4
    Expert confirmé
    Homme Profil pro
    Inscrit en
    Août 2010
    Messages
    3 453
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 3 453
    Par défaut
    Bonjour,

    Pas testé mais tu peux faire un mix des deux. Tu ne peux pas avoir deux procédures évènementielle du même nom dans le même module, le compilateur ne sachant laquelle appeler :
    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
     
    Private Sub Worksheet_Change(ByVal Target As Range)
     
        Application.EnableEvents = False
     
        If Target.Address = "$C$22" And Not (IsEmpty(Target.Value)) Then Range("F22").Value = Now Else Range("F22").ClearContents
        If Target.Address = "$C$23" And Not (IsEmpty(Target.Value)) Then Range("F23").Value = Now Else Range("F23").ClearContents
        If Target.Address = "$C$24" And Not (IsEmpty(Target.Value)) Then Range("F24").Value = Now Else Range("F24").ClearContents
        If Target.Address = "$C$25" And Not (IsEmpty(Target.Value)) Then Range("F25").Value = Now Else Range("F25").ClearContents
     
        Application.EnableEvents = True
     
        If Intersect(Target, Range("A22:A25")) Is Nothing Then: Exit Sub 'Supprimer pour toute la page
     
        With Target
     
            Select Case Target.Value
                Case Is = "A"
                    .Font.ColorIndex = 3 'caractère en rouge
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CEF"
                    .Font.ColorIndex = 7 'caractère en rose
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CET"
                    .Font.ColorIndex = 2 'caractère en blanc
                    With .Interior
                        .ColorIndex = 3 'fond rouge
                        .Pattern = xlSolid
                    End With
                Case Is = "CMAT"
                    .Font.ColorIndex = 46 'caractère en orange
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CPAT"
                    .Font.ColorIndex = 46 'caractère en orange
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CP"
                    .Font.ColorIndex = 5 'caractère en bleu
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CP½A"
                    .Font.ColorIndex = 5 'caractère en bleu
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CP½M"
                    .Font.ColorIndex = 5 'caractère en bleu
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CPE"
                    .Font.ColorIndex = 9 'caractère en marron
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CSS"
                    .Font.ColorIndex = 8 'caractère en turquoise
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "EMAL"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 7 'fond rose
                        .Pattern = xlSolid
                    End With
                Case Is = "EMAL½A"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 7 'fond rose
                        .Pattern = xlSolid
                    End With
                Case Is = "EMAL½M"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 7 'fond rose
                        .Pattern = xlSolid
                    End With
                Case Is = "MAL"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "MAL½A"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "MAL½M"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTT"
                    .Font.ColorIndex = 10 'caractère en vert
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTT½A"
                    .Font.ColorIndex = 10 'caractère en vert
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTT½M"
                    .Font.ColorIndex = 10 'caractère en vert
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTTE"
                    .Font.ColorIndex = 2 'caractère en blanc
                    With .Interior
                        .ColorIndex = 10 'fond vert
                        .Pattern = xlSolid
                    End With
                Case Is = "RTTE TRAV"
                    .Font.ColorIndex = 3 'caractère en rouge
                    With .Interior
                        .ColorIndex = 10 'fond vert
                        .Pattern = xlSolid
                    End With
                Case Else
                    .Font.ColorIndex = xlNone
                    .Interior.ColorIndex = xlNone
            End Select
     
        End With
     
    End Sub
    Hervé.

  5. #5
    Expert confirmé Avatar de jfontaine
    Homme Profil pro
    Contrôleur de Gestion
    Inscrit en
    Juin 2006
    Messages
    4 756
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Contrôleur de Gestion

    Informations forums :
    Inscription : Juin 2006
    Messages : 4 756
    Par défaut
    Je ne vois pas bien ton problème car ton code semble bien fonctionner. si ce n'est que la date se met uniquement si la Colonne F est alimentée, sans tenir compte de la colonne A

    Est ce cela ton problème ?

  6. #6
    Membre averti
    Femme Profil pro
    FORMATEUR BUREAUTIQUE
    Inscrit en
    Mai 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : FORMATEUR BUREAUTIQUE

    Informations forums :
    Inscription : Mai 2010
    Messages : 21
    Par défaut Peut on créer 2 Worksheet_Change à la suite dans la même feuille
    Bjr,

    Je vous remercie de votre aide, mais cela ne marche pas...

    Avec la méthode de Theze, merci pour ta proposition, mais cela ne marche pas.
    Il ne prend toujours en compte, qu'une seule procédure et surtout
    en colonne F, j'ai une fonction =SI($C22;AUJOURDHUI();"") qui s'efface systématiquement lorsque je rentre en case A, un choix, alors que la 1ère procédure devait SIMPLEMENT changer de valeur pour qu'à la prochaine ouverture, la date ne se modifie pas.

    En réponse à JFontaine : Quant à ma 1ère procédure, elle marche trés bien : chgt des couleurs en colonne A, mais ne marche plus sur la colonne F qui doit mettre la date du jour, mais aussitôt doit changer la valeur de la colonne F.

    Apparemment, il n'est pas possible de mettre 2 procédures à la suite...

    Si vous avez d'autres idées, je suis preneuse... car j'essaies des tas de choses, mais j'avoue que je suis dépassée, un peu trop "neuve" dans le métier.

    Encore merci

    Vérolyde

  7. #7
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 71
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Par défaut
    Citation Envoyé par VEROLYDE Voir le message
    Il ne prend toujours en compte, qu'une seule procédure
    Normal car
    Citation Envoyé par Theze Voir le message
    Tu ne peux pas avoir deux procédures évènementielle du même nom dans le même module, le compilateur ne sachant laquelle appeler
    Theze t'a pourtant indiqué une manière de procéder.

    Que se passe-t-il si tu utilises son code?
    N'oubliez pas de cliquer sur quand vous avez obtenu ou trouvé vous-même la réponse à votre question.
    Si vous trouvez seul, pensez à poster votre solution. Elle peut servir à d'autres!
    Pensez aussi à voter pour les réponses qui vous ont aidés.
    ------------
    Je dois beaucoup de mes connaissances à mes erreurs!

  8. #8
    Membre averti
    Femme Profil pro
    FORMATEUR BUREAUTIQUE
    Inscrit en
    Mai 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : FORMATEUR BUREAUTIQUE

    Informations forums :
    Inscription : Mai 2010
    Messages : 21
    Par défaut
    Bjr,

    Comme je l'ai indiqué précédemment dans mon msg, la proposition de THEZE ne marche pas non plus. Une seule des 2 procédures marchent (les chgts de couleurs) mais ne prend plus en compte ma demande de changer la valeur et enlève ma date.

    Merci à tous ceux qui tentent de m'aider !

    Je suis toujours à l'écoute...

    Et continu mes recherches.

    Vérolyde

  9. #9
    Expert confirmé
    Homme Profil pro
    Inscrit en
    Août 2010
    Messages
    3 453
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 3 453
    Par défaut
    Bonjour,

    Le code se comporte tout à fait bien comme tu l'a écris seulement, la programmation c'est en grande partie de la logique et donc il faut réfléchir !
    ecrire :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    If Target.Address = "$C$22" And Not (IsEmpty(Target.Value)) Then Range("F22").Value = Now Else Range("F22").ClearContents
    veux dire que si l'adresse de Target est = à $C$22 ET si Target n'est pas vide alors on exécute la commande :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Range("F22").Value = Now
    par contre si l'adresse de Target est <> de $C$22 OU si Target est vide, on exécute la commande :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Range("F22").ClearContents
    Donc, voici le code pour que les conditions soient testées séparément
    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
     
    Private Sub Worksheet_Change(ByVal Target As Range)
     
        Application.EnableEvents = False
     
        If Target.Address = "$C$22" Then
     
            If Target.Value <> "" Then
                Range("F22").Value = Now
            Else
                Range("F22").ClearContents
            End If
     
        End If
     
        If Target.Address = "$C$23" Then
     
            If Target.Value <> "" Then
                Range("F23").Value = Now
            Else
                Range("F23").ClearContents
            End If
     
        End If
     
        If Target.Address = "$C$24" Then
     
            If Target.Value <> "" Then
                Range("F24").Value = Now
            Else
                Range("F24").ClearContents
            End If
     
        End If
     
        If Target.Address = "$C$25" Then
     
            If Target.Value <> "" Then
                Range("F25").Value = Now
            Else
                Range("F25").ClearContents
            End If
     
        End If
     
        Application.EnableEvents = True
     
        If Intersect(Target, Range("A22:A25")) Is Nothing Then: Exit Sub 'Supprimer pour toute la page
     
        With Target
     
            Select Case Target.Value
                Case Is = "A"
                    .Font.ColorIndex = 3 'caractère en rouge
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CEF"
                    .Font.ColorIndex = 7 'caractère en rose
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CET"
                    .Font.ColorIndex = 2 'caractère en blanc
                    With .Interior
                        .ColorIndex = 3 'fond rouge
                        .Pattern = xlSolid
                    End With
                Case Is = "CMAT"
                    .Font.ColorIndex = 46 'caractère en orange
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CPAT"
                    .Font.ColorIndex = 46 'caractère en orange
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CP"
                    .Font.ColorIndex = 5 'caractère en bleu
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CP½A"
                    .Font.ColorIndex = 5 'caractère en bleu
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CP½M"
                    .Font.ColorIndex = 5 'caractère en bleu
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CPE"
                    .Font.ColorIndex = 9 'caractère en marron
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "CSS"
                    .Font.ColorIndex = 8 'caractère en turquoise
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "EMAL"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 7 'fond rose
                        .Pattern = xlSolid
                    End With
                Case Is = "EMAL½A"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 7 'fond rose
                        .Pattern = xlSolid
                    End With
                Case Is = "EMAL½M"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 7 'fond rose
                        .Pattern = xlSolid
                    End With
                Case Is = "MAL"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "MAL½A"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "MAL½M"
                    .Font.ColorIndex = 1 'caractère en noir
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTT"
                    .Font.ColorIndex = 10 'caractère en vert
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTT½A"
                    .Font.ColorIndex = 10 'caractère en vert
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTT½M"
                    .Font.ColorIndex = 10 'caractère en vert
                    With .Interior
                        .ColorIndex = 2 'fond blanc
                        .Pattern = xlSolid
                    End With
                Case Is = "RTTE"
                    .Font.ColorIndex = 2 'caractère en blanc
                    With .Interior
                        .ColorIndex = 10 'fond vert
                        .Pattern = xlSolid
                    End With
                Case Is = "RTTE TRAV"
                    .Font.ColorIndex = 3 'caractère en rouge
                    With .Interior
                        .ColorIndex = 10 'fond vert
                        .Pattern = xlSolid
                    End With
                Case Else
                    .Font.ColorIndex = xlNone
                    .Interior.ColorIndex = xlNone
            End Select
     
        End With
     
    End Sub
    Hervé.

  10. #10
    Membre averti
    Femme Profil pro
    FORMATEUR BUREAUTIQUE
    Inscrit en
    Mai 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : FORMATEUR BUREAUTIQUE

    Informations forums :
    Inscription : Mai 2010
    Messages : 21
    Par défaut
    Un grand MERCI à THEZE, tu es formidable..

    Cela marche trés bien !!!!

    Je tiens tout de même à remercier tous ceux qui se sont intéressés à mon pb.

    Je vais en formation macro (lundi et mardi), j'espère pouvoir apporté un peu ma contribution à ceux qui auront besoin d'aide sur le forum...

    Bonne journée !

    Vérolyde

  11. #11
    Expert confirmé
    Homme Profil pro
    Inscrit en
    Août 2010
    Messages
    3 453
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 3 453
    Par défaut
    Re,

    C'est aussi en aidant les autres qu'on apprend, il ne faut pas rester seul dans son coin. Si tu réponds faux à une question, personne ne t'en voudra mais pour toi ce sera une leçon apprise

    Hervé.

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

Discussions similaires

  1. [XL-2007] Boucle pour copier des valeurs à la suite dans une même feuille
    Par LaMite dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 28/04/2014, 19h21
  2. Réponses: 7
    Dernier message: 29/11/2010, 22h52
  3. une action dans excel peut elle créer une ligne de code dans VBA?
    Par beebe dans le forum Macros et VBA Excel
    Réponses: 12
    Dernier message: 25/09/2008, 08h23
  4. Réponses: 1
    Dernier message: 18/01/2008, 13h49
  5. style de lien différents dans la même feuille de style
    Par seb nantes dans le forum Mise en page CSS
    Réponses: 3
    Dernier message: 08/07/2007, 18h28

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