Bonjour à tous,

Je suis en train de réaliser une macro pour créer un TCD, mais j'ai un bug qui s'affiche. J'ai récupérer le code à partir de l'aide de microsoft office.

Voici le bout de code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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

Le message d'erreur est le suivant : La méthode PivotTableWizar de l'objet worksheet a échoué.

Pourriez-vous m'expliquer le problème, je précise que je suis débutant sur VBA.


Merci d'avance pour votre aide.