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
| Sub Macro1()
ActiveSheet.Unprotect
Cells.Select 'sélection de la feuille
ActiveWorkbook.Styles.Add Name:="New style"
With ActiveWorkbook.Styles("New style")
.IncludeNumber = True
.IncludeFont = True
.IncludeAlignment = True
.IncludeBorder = True
.IncludePatterns = True
.IncludeProtection = True
End With
'Début de la modification du nouveau style - tout n'est pas modifié
ActiveWorkbook.Styles("New style").NumberFormat = "# ##0,00"
With ActiveWorkbook.Styles("New style").Font
.Name = "Roman" 'ici
.Size = 10
.Bold = True 'ici
.Italic = False
.Underline = xlUnderlineStyleNone
.Strikethrough = False
.ColorIndex = 3 'ici
End With
With ActiveWorkbook.Styles("New style")
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter 'ici
.WrapText = True 'ici
.Orientation = 0
.IndentLevel = 0
.ShrinkToFit = False
End With
'Modification de l'encadrement de la cellule
With ActiveWorkbook.Styles("New style").Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With ActiveWorkbook.Styles("New style").Borders(xlRight)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With ActiveWorkbook.Styles("New style").Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With ActiveWorkbook.Styles("New style").Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
ActiveWorkbook.Styles("New style").Borders(xlDiagonalDown).LineStyle = xlNone
ActiveWorkbook.Styles("New style").Borders(xlDiagonalUp).LineStyle = xlNone
'Modif du fond
With ActiveWorkbook.Styles("New style").Interior
.ColorIndex = 35
.PatternColorIndex = xlAutomatic
.Pattern = xlSolid
End With
'On remet toute la feuille au style normal
Selection.Style = "Normal"
'Selection de la cellule à modifir et effectation du style créé
Range("F12").Select
Selection.Style = "New style"
'On re-protège la feuille
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub |
Partager