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
| Sub macro_tcd()
Dim objTable As PivotTable, objField As PivotField
' Select the sheet and first cell of the table that contains the data.
ActiveWorkbook.Sheets("cas avec intervention").Select
Range("A1").Select
' Create the PivotTable object based on the Employee data on Sheet1.
Set objTable = Feuil3.PivotTableWizard
' Specify row and column fields.
Set objField = objTable.PivotFields("Dos.Nom de l’UI")
objField.Orientation = xlRowField
Set objField = objTable.PivotFields("Dos.Nom de l’UI")
objField.Orientation = xlRowField
' Specify a data field with its summary
' function and format.
Set objField = objTable.PivotFields("Dos.Nom de l’UI")
objField.Orientation = xlDataField
objField.Function = xlCount
MsgBox "Création du TCD"
End Sub |