Sub ventes_mensuelles_commerciaux()
' Dégrouper les colonnes
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=2
Dim wbkVentesMensuellesCommerciaux As Workbook, pathWbkVentesMensuellesCommerciaux As String
'définir le chemin du classeur "Ventes commerciaux.xls"
pathWbkVentesMensuellesCommerciaux = ThisWorkbook.Path & "\Ventes mensuelles commerciaux.xls"
'ouvrir le classeur "Ventes commerciaux.xlsx"
Set wbkVentesMensuellesCommerciaux = Application.Workbooks.Open(pathWbkVentesMensuellesCommerciaux, , False)
' Effectuer le copier coller
Dim Wb As Workbook
'Application.Calculation = xlCalculationManual
nf = [Large(AA:AA, 1)]
fichier = ThisWorkbook.Path & "\Ventes mensuelles commerciaux.xls"
Set Wb = GetObject(fichier)
With Workbooks(ThisWorkbook.Name)
lg = Wb.Sheets("Ventes totales").Range("AA65536").End(xlUp).Row + 1
For n = 2 To .Sheets("VTE QUERY").Range("AA65536").End(xlUp).Row
If Val(Wb.Sheets("VTE QUERY").Range("AA" & n).Value) > nf Then
Wb.Sheets("Ventes totales").Range("A" & lg & ":AB" & lg).Value = _
.Sheets("VTE QUERY").Range("A" & n & ":AB" & n).Value
lg = lg + 1
End If
Next n
End With
'Wb.Close
'Application.Calculation = xlCalculationAutomatic
' Mise en page centrer + format date
Wb.Sheets("Ventes totales").Select
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Wb.Sheets("Ventes totales").Select
Columns("Y:Z").Select
Range("Y2281").Activate
Selection.NumberFormat = "d/m/yy;@"
'Se placer sur la dernière facture de Ventes totales
Wb.Sheets("Ventes totales").Select
Range("AA1").Select
Selection.End(xlDown).Select
ActiveWindow.SmallScroll Down:=9
End Sub