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
| Sub test()
For Each Sheet In ActiveWorkbook.Worksheets
If Sheet.Name = "Macro" Then
Application.DisplayAlerts = False
Worksheets("Macro").Delete
Application.DisplayAlerts = True
End If
Next Sheet
With ThisWorkbook
.Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = "Macro"
End With
Sheets("Macro").Activate
Cells(1, 1) = "Jan."
Cells(2, 1) = "Fev."
Cells(3, 1) = "Mars"
Cells(4, 1) = "Avril"
Cells(5, 1) = "Mai"
Cells(6, 1) = "Juin"
Cells(7, 1) = "Jui."
Cells(8, 1) = "Aout"
Cells(9, 1) = "Sept"
Cells(10, 1) = "Oct"
Cells(11, 1) = "Nov."
Cells(12, 1) = "Déc."
an = InputBox("Indiquer le mois et l'année :", "Sélection du mois pour le filtre", "Format : 20XX")
Dim mois As Integer
For mois = 1 To 12
Worksheets("DA").Range("$M:$M").AutoFilter Field:=13, Operator:= _
xlFilterValues, Criteria2:=Array(1, Format(DateSerial(an, mois, 1), "mm/dd/yyyy"))
Sheets("DA").Activate
TFT_MOIS = Worksheets("DA").Range("M:M").Application.WorksheetFunction.Subtotal(3, Range("M:M"))
Sheets("Macro").Activate
Cells(mois, 2) = TFT_MOIS - 1
Next
Sheets("DA").Activate
ActiveSheet.Range("$A$1:$BH$1163").AutoFilter Field:=13, Operator:= _
xlFilterValues, Criteria2:=Array(0, Format(DateSerial(an, 12, 31), "mm/dd/yyyy"))
TFT_TOTAL = Worksheets("DA").Range("M:M").Application.WorksheetFunction.Subtotal(3, Range("M:M"))
Sheets("Macro").Activate
Cells(1, 4) = "Nombre de TFT Depuis le début de l'année :"
Cells(1, 5) = TFT_TOTAL - 1
'Création du graphique
ActiveCell.Range("A1:B12").Select
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Range("Macro!$A$1:$B$12")
ActiveChart.SetElement (msoElementChartTitleNone)
ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 215
ActiveSheet.Shapes("Graphique 1").Height = 146.2677165354
ActiveSheet.Shapes("Graphique 1").Width = 318.8976377953
End Sub |
Partager