Simplification code vba

relax93

XLDnaute Nouveau
Bonjour , pouvez vous m'aidez a simplifiez ces lignes de vba svp

Sub titrage()
'
' titrage Macro
'

'
Range("D7").Select
ActiveCell.FormulaR1C1 = "Macro titrage"
Range("D7").Select
ActiveCell.FormulaR1C1 = "Macro titrage"
Range("D7").Select
ActiveCell.FormulaR1C1 = "Macro titrage"
Range("D7").Select
ActiveCell.FormulaR1C1 = "Macro titrage"
Columns("D:D").Select
Selection.ColumnWidth = 21.5
Range("D7").Select
ActiveCell.FormulaR1C1 = "Macro titrage"
Range("D7").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
Columns("D:D").Select
Selection.ColumnWidth = 25.38
Range("D7").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark2
.TintAndShade = -0.499984740745262
.PatternTintAndShade = 0
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = -0.249977111117893
.PatternTintAndShade = 0
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("D7").Select
End Sub
 

jecherche

XLDnaute Occasionnel
Re : Simplification code vba

Bonjour,

Une première étape ... sans avoir besoin de sélectionner la cellule :
Code:
Sub titrage()

[D7] = "Macro titrage"
[D7].ColumnWidth = 25.8

With [D7].Interior
  .Pattern = xlSolid
  .PatternColorIndex = xlAutomatic
  .Color = 5296274
  .TintAndShade = 0
  .PatternTintAndShade = 0
End With

With [D7].Borders(xlEdgeLeft)
  .LineStyle = xlContinuous
  .ColorIndex = 0
  .TintAndShade = 0
  .Weight = xlThin
End With

With [D7].Borders(xlEdgeTop)
  .LineStyle = xlContinuous
  .ColorIndex = 0
  .TintAndShade = 0
  .Weight = xlThin
End With

With [D7].Borders(xlEdgeBottom)
  .LineStyle = xlContinuous
  .ColorIndex = 0
  .TintAndShade = 0
  .Weight = xlThin
End With

With [D7].Borders(xlEdgeRight)
  .LineStyle = xlContinuous
  .ColorIndex = 0
  .TintAndShade = 0
  .Weight = xlThin
End With

With [D7]
  .HorizontalAlignment = xlCenter
  .VerticalAlignment = xlCenter
  .WrapText = False
  .Orientation = 0
  .AddIndent = False
  .IndentLevel = 0
  .ShrinkToFit = False
  .ReadingOrder = xlContext
  .MergeCells = False
End With

[D7].Borders(xlDiagonalDown).LineStyle = xlNone
[D7].Borders(xlDiagonalUp).LineStyle = xlNone

''Range("D7").Select
End Sub


Jecherche
 

relax93

XLDnaute Nouveau
Re : Simplification code vba

D'accord merci,
j'ai deja fais ca


Sub simpletitre()
'
' titrage Macro simplifié

'

'
Range("D7").Select
ActiveCell.FormulaR1C1 = "Macro titrage"
Columns("D:D").Select
Selection.ColumnWidth = 21.5
Range("D7").Select
ActiveCell.FormulaR1C1 = "Macro titrage"
Range("D7").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.399975585192419
End With
Columns("D:D").Select
Selection.ColumnWidth = 25.38
Range("D7").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark2
.TintAndShade = -0.499984740745262
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = -0.249977111117893
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.ReadingOrder = xlContext

End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ReadingOrder = xlContext

End With
Range("D7").Select
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 193
Messages
2 086 062
Membres
103 110
dernier inscrit
Privé