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 :

Perte de Mise en forme conditionnelle après ouverture fichier


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 Perte de Mise en forme conditionnelle après ouverture fichier
    Bonjour,

    En vba, j'ai créé un fichier avec des "mise en forme conditionnelle" puis enregistrer le fichier

    Or, lorsque j'ouvre le fichier les règles de mise en forme conditionnelle ont disparu alors qu'avant l'enregistrement je les voyait toujours

    Je ne trouve pas pourquoi ?

    merci pour votre aide

  2. #2
    Membre du Club
    Homme Profil pro
    Ingénieur après-vente
    Inscrit en
    Octobre 2014
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Ingénieur après-vente
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2014
    Messages : 24
    Points : 46
    Points
    46
    Par défaut
    sous quel format as-tu enregistré ton fichier? en enregistrant le fichier en tant que fichier excel depuis ton Excel, il n'y a aucue raison d'avoir un ecart de fonctionnalités entre l'enregistrement et la réouverture.
    Si il n'y a pas de solution, c'est qu'il n'y a pas de problème!

  3. #3
    Expert éminent sénior
    Homme Profil pro
    aucune
    Inscrit en
    Septembre 2011
    Messages
    8 203
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Septembre 2011
    Messages : 8 203
    Points : 14 354
    Points
    14 354
    Par défaut
    Bonjour,

    Poste ton code.
    Cordialement.

    Daniel

    La plus perdue de toutes les journées est celle où l'on n'a pas ri. Chamfort

  4. #4
    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
    Voici le code :

    Mon application est en Xlsm et mes fichiers en xls

    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
     Sheets(3).Activate
                Sheets(3).Name = "Pieces_Supplementaires_" & MagTech
                Cells(1, 1) = "ARTICLE"
                Cells(1, 2) = "LIBELLE ARTICLE"
                Cells(1, 3) = "MAGASIN"
                Cells(1, 4) = "EMPLACEMENT"
                Cells(1, 5) = "UDM"
                Cells(1, 6) = "VERSION"
                Cells(1, 7) = "LOT"
                Cells(1, 8) = "SERIE"
                Cells(1, 9) = "QTE COMPTEE"
                Cells(1, 10) = "COMMENTAIRE TECHNICIEN"
                Cells(1, 11) = "COMPLEMENT"
                Cells(1, 12) = "OBSERVATION RIL"
                Cells(1, 13) = "BT ASSOCIE"
                Cells(1, 14) = "LIBELLE SITE"
                Range("A1:N1").Select
                Call ListeDéroulanteSup(10, "A:I", "J:N")
                Call ConditionsCelluleSUP
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .ThemeColor = xlThemeColorLight2
                    .TintAndShade = 0.399975585192419
                    .PatternTintAndShade = 0
                End With
                Columns("A:A").EntireColumn.AutoFit
                Columns("B:B").EntireColumn.AutoFit
                Columns("I:I").EntireColumn.AutoFit
                Columns("J:J").EntireColumn.AutoFit
                Columns("K:K").EntireColumn.AutoFit
                Columns("L:L").EntireColumn.AutoFit
                Columns("M:M").EntireColumn.AutoFit
                Columns("N:N").EntireColumn.AutoFit
                Columns("D:D").EntireColumn.AutoFit
                Columns("C:C").EntireColumn.AutoFit
                Columns("B:B").EntireColumn.AutoFit
                Columns("A:A").EntireColumn.AutoFit
                'ActiveWorkbook.Protect Password:="INVTOURNANT", Structure:=True
                Application.DisplayAlerts = False
                ActiveWorkbook.SaveAs Filename:=CheminRetourFiche & "\" & NomClasseurTech, FileFormat:=xlExcel8, ConflictResolution:=xlLocalSessionChanges
                Workbooks(NomClasseurTech).Close
                Application.DisplayAlerts = True
                            With Sheets("Liste techs")
                            Set Rg = .Columns(NColonneTechs + 1).Find(NomClasseurTech, lookat:=xlWhole)
                    If Not Rg Is Nothing Then
                        .Cells(Rg.Row, NColonneTechs + 3) = "C" 'Fichier créé
                        .Cells(Rg.Row, NColonneTechs + 4) = NLigneProt1 - 1
                        .Cells(Rg.Row, NColonneTechs + 5) = NLigneProt2 - 1
                    End If

    et le prog fait appel ConditionsCelluleSup dont voici le prog

    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
    Sub ConditionsCelluleSUP()
    '
    Dim NbLigne As Integer
    Dim i As Integer
     '
    NbLigne = Cells(1, 1).CurrentRegion.Rows.Count
    Cells(2, 15).Select
    ActiveCell.FormulaR1C1 = _
        "=IF(RC[-5]=""Récupéré sur Site"",""Préciser le code IG du site où a été récupéré le module"",IF(RC[-5]=""Déposé en pied de site"",""Préciser le code IG du site où a été mis le module"",IF(RC[-5]=""Matériel installé"",""Préciser le code IG où a été installé le module"",IF(RC[-5]=""Transféré à un autre technicien"",""Préciser le nom du technicien"",IF(RC[-5]=""Autres"",""Merci de préciser"","""")))))"
    '
    Selection.FormatConditions.Add Type:=xlTextString, String:= _
        "=""Préciser le code IG du site où a été récupéré le module""", TextOperator:=xlContains
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    '
    Selection.FormatConditions.Add Type:=xlTextString, String:= _
        "=""Préciser le code IG du site où a été mis le module""", TextOperator:=xlContains
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    '
    Selection.FormatConditions.Add Type:=xlTextString, String:= _
        "=""Préciser le code IG où a été installé le module""", TextOperator:=xlContains
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    '
    Selection.FormatConditions.Add Type:=xlTextString, String:= _
        "=""Préciser le nom du technicien""", TextOperator:=xlContains
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    '
    Selection.FormatConditions.Add Type:=xlTextString, String:= _
        "=""Merci de préciser""", TextOperator:=xlContains
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16383844
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 13551615
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    '
    Range("S2").Select
    Selection.Copy
    Range(Cells(3, 19), Cells(NbLigne, 19)).Select
    ActiveSheet.Paste
    '
    End Sub

    j'ai fait du pas à pas pour vérifier que j'ai bien les couleurs juste avant l'enregistrement, ce qui est le cas

    merci d'avance

  5. #5
    Expert éminent sénior

    Profil pro
    Conseil, Formation, Développement - Indépendant
    Inscrit en
    Février 2010
    Messages
    8 421
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Conseil, Formation, Développement - Indépendant

    Informations forums :
    Inscription : Février 2010
    Messages : 8 421
    Points : 16 265
    Points
    16 265
    Par défaut
    Bonjour

    Enregistres-tu en xls ou xlsm ?
    Chris
    PowerQuery existe depuis plus de 13 ans, est totalement intégré à Excel 2016 &+. Utilisez-le !

    Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson.
    Confucius

    ----------------------------------------------------------------------------------------------
    En cas de résolution, n'hésitez pas cliquer sur c'est toujours apprécié...

  6. #6
    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
    ils sont enregistrés en xls

  7. #7
    Expert éminent sénior
    Homme Profil pro
    aucune
    Inscrit en
    Septembre 2011
    Messages
    8 203
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Septembre 2011
    Messages : 8 203
    Points : 14 354
    Points
    14 354
    Par défaut
    Bonjour,

    Comme apparemment tu enregistres en XLS, le fait d'avoir plus de trois conditions de MFC déplaît à Excel.
    Cordialement.

    Daniel

    La plus perdue de toutes les journées est celle où l'on n'a pas ri. Chamfort

  8. #8
    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
    c'est exact, je viens de modifier ma condition pour en avoir une seule et cela fonctionne
    merci

  9. #9
    Membre régulier
    Homme Profil pro
    Ressources humaines
    Inscrit en
    Mai 2020
    Messages
    150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ressources humaines
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2020
    Messages : 150
    Points : 75
    Points
    75
    Par défaut
    Citation Envoyé par Daniel.C Voir le message
    Bonjour,

    Comme apparemment tu enregistres en XLS, le fait d'avoir plus de trois conditions de MFC déplaît à Excel.
    Hello, désolé de casser un peu l'ambiance mais :
    Faux : je passe, plutot je passais, mon temps à générer des MFC sous xlsm - et non xls - et celà ne tient pas, ou pas bien, ou/et en partie, ou rien. Du grand n'importe quoi : certaines cells ont conservé certaines MFC, d'autres non, pas les mêmes, etc...
    Evidemment les "explications" de microfault sont nulles, laconiques et hors sujets (quand ils n'ont aucune réponse ultra standard ils emploient toujours cette méthode : des réponses où l'on se dit "suis-je super-nul/con, ou serait-il possible que ce soit eux ?...Non, ils sont forcément géniaux, ce doit etre moi...)

    Donc les MFC, c'est de la pure m...
    faut coder.

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

Discussions similaires

  1. [XL-2010] Mise en forme conditionnelle après rechercheV
    Par lovely2604 dans le forum Conception
    Réponses: 9
    Dernier message: 21/11/2014, 14h58
  2. [PHPExcel] Perte du format Mise en forme conditionnel
    Par guigui69 dans le forum Bibliothèques et frameworks
    Réponses: 0
    Dernier message: 14/02/2014, 10h40
  3. Réponses: 2
    Dernier message: 15/07/2011, 23h57
  4. Réponses: 4
    Dernier message: 15/11/2005, 18h53
  5. Mise en forme conditionnelle en VBA / Cut-Paste
    Par priest69 dans le forum IHM
    Réponses: 4
    Dernier message: 03/09/2005, 13h54

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