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
| Private tb As Object
Public Enum PivotType
Typeligne = 1
TypeColonne = 2
TypeFiltre = 3
End Enum
Public Enum Fonct
Somme = -4157
Nombre = -4112
Moyenne = -4106
Max = -4136
Min = -4139
Produit = -4149
Chiffres = -4113
Écartype = -4155
Écartypep = -4156
Var = -4164
VarP = -4165
End Enum
Public Function CreerTableau(Wb As Workbook, palge As String, Name As String)
Dim Ws As Worksheet
Set Ws = Sheets.Add
Set tb = Wb.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
palge, Version:=xlPivotTableVersion12)
Set tb = tb.CreatePivotTable( _
TableDestination:=Ws.Range("A1"), TableName:=Name, _
DefaultVersion:=xlPivotTableVersion12)
End Function
Public Sub NewPivotTables(Fld As String, Orientation As PivotType, Optional SousTotaux As Boolean)
With tb.PivotFields(Fld)
.Orientation = Orientation
If SousTotaux = False Then
.LayoutSubtotalLocation = 1
Else
.LayoutSubtotalLocation = 2
End If
'.Position = 1
End With
End Sub
Public Sub NewDataField(Fld As String, Optional Fonction As Fonct = Somme)
tb.AddDataField tb.PivotFields(Fld), " " & Fld, Fonction
End Sub
Public Sub AfficheTotal(Linge As Boolean, Colone As Boolean)
tb.ColumnGrand = Colone
tb.RowGrand = Linge
End Sub
Public Sub Style(S As String)
tb.TableStyle2 = S
End Sub |
Partager