Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Une macro enregistré ne fonctionne pas : run time error 438

2 réponses
Avatar
ljaxor
Bonjour,

J'ai enregistré une macro mais elle plante a l'execution.
En fait dans mon fichier excel principal, j'ouvre un fichier txt et je cree
une table de pivot a partir de la worksheet "back_miss_probes".
Le probleme c'est que j'ai toujours l'erreur "run time error 438 , object
doesn't support this property or method" sur la ligne :
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)

I suspecte un problem d'active sheet mais je n'arrive pas a la faire marcher.

Sub macrolja()

'Windows("back_miss_probes.txt").Activate
'Sheets("back_miss_probes").Select
'si de décommente les lignes ci-dessus, j'ai "run time error 9, subscript
out of range"

Columns("H:H").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"back_miss_probes!H:H").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
With ActiveSheet.PivotTables("PivotTable1").PivotFields("shadow source")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("shadow source")
.Orientation = xlDataField
.Position = 1
End With
Range("B6").Select
Selection.Sort Key1:="R6C2", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Pivot"
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Pivot").Range("B6")
ActiveChart.Location Where:=xlLocationAsNewSheet
Sheets("Chart1").Select
Sheets("Chart1").Name = "Pivot_chart"
Application.CommandBars("PivotTable").Visible = False
End Sub


Voici la macro :

2 réponses

Avatar
isabelle
bonjour ljaxor,

peut être ne faut il pas indiqué la feuille,
ActiveSheet.PivotTableWizard TableDestination:Îlls(3, 1)

isabelle


Bonjour,

J'ai enregistré une macro mais elle plante a l'execution.
En fait dans mon fichier excel principal, j'ouvre un fichier txt et je cree
une table de pivot a partir de la worksheet "back_miss_probes".
Le probleme c'est que j'ai toujours l'erreur "run time error 438 , object
doesn't support this property or method" sur la ligne :
ActiveSheet.PivotTableWizard TableDestination:¬tiveSheet.Cells(3, 1)

I suspecte un problem d'active sheet mais je n'arrive pas a la faire marcher.

Sub macrolja()

'Windows("back_miss_probes.txt").Activate
'Sheets("back_miss_probes").Select
'si de décommente les lignes ci-dessus, j'ai "run time error 9, subscript
out of range"

Columns("H:H").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"back_miss_probes!H:H").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:¬tiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
With ActiveSheet.PivotTables("PivotTable1").PivotFields("shadow source")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("shadow source")
.Orientation = xlDataField
.Position = 1
End With
Range("B6").Select
Selection.Sort Key1:="R6C2", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Pivot"
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Pivot").Range("B6")
ActiveChart.Location Where:=xlLocationAsNewSheet
Sheets("Chart1").Select
Sheets("Chart1").Name = "Pivot_chart"
Application.CommandBars("PivotTable").Visible = False
End Sub


Voici la macro :



Avatar
ljaxor
Merci pour l'idée.
En fait, j'ai réussi a la faire marcher en indiquant a chaque ligne les
references completes :
Ex
Application.Workbooks("back_miss_probes.txt").Sheets("Pivot").PivotTables("PivotTable3").SmallGrid = False

Laurent