Private Sub CommandButton1_Click()
With Me 'fait référence à la feuille contenant le code, indépendamment
'de son nom d'onglet.
' Détermination du nom de la feuille
MsgBox ("Le nom de la feuille : " & .CodeName)
' Détermination du nom de l'onglet
MsgBox ("Le nom de l'onglet : " & .Name)
' Tri des données en fonction du N° de compte et de la section analytique
With .Sort
With .SortFields
.Clear
.Add Key:=.Parent.Parent.Range("A2:A5000"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortTextAsNumbers
.Add Key:=.Parent.Parent.Range("G2:G5000"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
End With
.SetRange .Parent.Range("A1:P5000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' Mise en forme des colonnes de dates
.Range("D:E,O:O").NumberFormat = "dd/mm/yy;@"
' Mise en forme des colonnes des montants
.Range("F:F,I:I,L:N").NumberFormat = "#,##0.00_ ;[Red]-#,##0.00 ;_-* ""-""?? _€_-"
' Mise en forme du cadre
DerLigne = .Cells(.Rows.Count, 1).End(xlUp).Row
With .Range("A1:P" & DerLigne).Borders
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Item(xlEdgeLeft).Weight = xlThin
.Item(xlEdgeTop).Weight = xlThin
.Item(xlEdgeBottom).Weight = xlThick
.Item(xlEdgeRight).Weight = xlThick
.Item(xlInsideVertical).Weight = xlThin
.Item(xlInsideHorizontal).Weight = xlHairline
End With
' Mise en forme de l'entête des colonnes
With .Range("A1:P1")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
With .Font
.Name = "Tahoma"
.FontStyle = "Gras"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = 10040064
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With .Borders
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Item(xlEdgeLeft).Weight = xlThin
.Item(xlEdgeTop).Weight = xlThin
.Item(xlEdgeBottom).Weight = xlMedium
.Item(xlEdgeRight).Weight = xlThick
.Item(xlInsideVertical).Weight = xlThin
.Item(xlInsideHorizontal).LineStyle = xlNone
End With
With .Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 6750156
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End With
'Figeage des volets
.Cells(2, 2).Activate
ActiveWindow.FreezePanes = True
End With
End Sub