Macro qui fonctionne dans un fichier Excel mais pas dans un autre
Bonjour,
J'ai récupéré une macro dans un fichier, qui coloris des lignes et change la Font du texte en fonction de variables.
Cela fonctionne très bien dans le fichier d'origine, mais pas dans le nouveau fichier.
Quelles pourraient-être les causes ?
Merci
Voici le code : (j'ai mis du texte pour m'y retrouver car je débute en VBA ;-)) )
Code:
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
| Option Explicit
Sub crea_recherche() 'Mise en forme ligne
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim i As Double
Dim post As Double
Dim derlign As Double
Dim test As Variant
Sheets("travail").Activate 'onglet travail actif
derlign = Range("A" & Rows.Count).End(xlUp).Row 'dernière ligne colonne A
For post = 13 To derlign 'Post= ligne 13 à dernière ligne
If Range("F" & post) = "" Then 'Si colonne G vide
Range("A" & post, "G" & post).Select 'Sélection Colonne A à G
With Selection
.HorizontalAlignment = xlCenter 'centrage texte
.VerticalAlignment = xlBottom
End With
With Selection.Interior
.ThemeColor = xlThemeColorLight2 'Fond de couleur
.TintAndShade = 0.399975585192419
End With
With Selection.Font 'Police Arial ...
.Name = "Arial"
.Size = 11
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.Font.Bold = True 'Gras
Selection.Merge
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop) 'Bordure
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom) 'Bordure
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
End If
Next post
Sheets("travail").Activate
Application.ScreenUpdating = True 'Mise à jour travail
Application.DisplayAlerts = True
End Sub |