Erreur d'execution '-2147417848' pivotcache
Résolu
chaymaek
Messages postés
6
Statut
Membre
-
chaymaek Messages postés 6 Statut Membre -
chaymaek Messages postés 6 Statut Membre -
Bonjour,
J'ai une erreur sur l'objet pivotcache de createpivottable (ligne en gras)
Est ce quelqu'un saurait d'où vient le problème ?
Mon code sert à faire des modification sur le fichier de base brut et puis crée un TCD..
Je vous remercie d'avance pour votre aide
Cordialement,
CK
Sub MEPISO()
Application.ScreenUpdating = False
' AJOUTER NOUVELLE COLONNE ARTICLE
Worksheets(1).Select
Columns("K:K").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("K1").Value = "Article"
' DEFINIR LES PARAMETRES
Dim i As Integer
Dim LR As Long
LR = WorksheetFunction.CountA(Range("A:A"))
' REMPLIR COLONNE ARTICLE
For i = 2 To LR
Cells(i, 11) = Cells(i, 9) & Cells(i, 10)
Next i
' AJOUTER NOUVELLE COLONNE ORDERED ML
Worksheets(1).Select
Columns("R:R").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("R1").Value = "Ordered ML"
0
' REMPLIR COLONNE ORDERED ML
For i = 2 To LR
Cells(i, 18) = Cells(i, 17) * Cells(i, 16)
Next i
' AJOUTER NOUVELLE COLONNE CONCATENER
Worksheets(1).Select
Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B1").Value = "Concatener"
' REMPLIR COLONNE CONCATENER
For i = 2 To LR
Cells(i, 2) = Cells(i, 1) & Cells(i, 11) & Cells(i, 16)
Next i
' SUPPRIMER LES DOUBLONS
ActiveSheet.Range("A:BM").RemoveDuplicates Columns:=2, Header:=xlYes
' AJOUTER TCD
' DECLARATION DES PARAMETRES
Dim sht As Worksheet
Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
Dim pf As String
Dim pf_Name As String
' DATA SOURCE
SrcData = ActiveSheet.Name & "!" & Range("A1:BM30000").Address(ReferenceStyle:=xlR1C1)
' CREATION NOUVELLE FEUILLE
Set sht = Sheets.Add
sht.Name = "TCD"
' LOCALISATION TCD
StartPvt = sht.Name & "!" & sht.Range("A3").Address(ReferenceStyle:=xlR1C1)
' CREATION PIVOT CACHE
Set pvtCache = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=SrcData)
' CREATION TCD A PARTIR DU PIVOT CACHE
Set pvt = pvtCache.CreatePivotTable(TableDestination:=StartPvt, TableName:="PivotTable1")
' AJOUTER CHAMPS LIGNE
pvt.PivotFields("Article").Orientation = xlRowField
' AJOUTER CHAMPS COLONNE
pvt.PivotFields("suppliername").Orientation = xlColumnField
' AJOUTER CHAMPS VALEUR
pf = "Ordered ML"
pf_Name = "Somme Ordered"
pvt.AddDataField pvt.PivotFields("Ordered ML"), pf_Name, xlSum
' ENLEVER VIDE DES FILTRES
With Sheets("TCD").PivotTables("PivotTable1").PivotFields("Suppliername")
.PivotItems("(blank)").Visible = False
End With
End Sub
J'ai une erreur sur l'objet pivotcache de createpivottable (ligne en gras)
Est ce quelqu'un saurait d'où vient le problème ?
Mon code sert à faire des modification sur le fichier de base brut et puis crée un TCD..
Je vous remercie d'avance pour votre aide
Cordialement,
CK
Sub MEPISO()
Application.ScreenUpdating = False
' AJOUTER NOUVELLE COLONNE ARTICLE
Worksheets(1).Select
Columns("K:K").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("K1").Value = "Article"
' DEFINIR LES PARAMETRES
Dim i As Integer
Dim LR As Long
LR = WorksheetFunction.CountA(Range("A:A"))
' REMPLIR COLONNE ARTICLE
For i = 2 To LR
Cells(i, 11) = Cells(i, 9) & Cells(i, 10)
Next i
' AJOUTER NOUVELLE COLONNE ORDERED ML
Worksheets(1).Select
Columns("R:R").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("R1").Value = "Ordered ML"
0
' REMPLIR COLONNE ORDERED ML
For i = 2 To LR
Cells(i, 18) = Cells(i, 17) * Cells(i, 16)
Next i
' AJOUTER NOUVELLE COLONNE CONCATENER
Worksheets(1).Select
Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B1").Value = "Concatener"
' REMPLIR COLONNE CONCATENER
For i = 2 To LR
Cells(i, 2) = Cells(i, 1) & Cells(i, 11) & Cells(i, 16)
Next i
' SUPPRIMER LES DOUBLONS
ActiveSheet.Range("A:BM").RemoveDuplicates Columns:=2, Header:=xlYes
' AJOUTER TCD
' DECLARATION DES PARAMETRES
Dim sht As Worksheet
Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
Dim pf As String
Dim pf_Name As String
' DATA SOURCE
SrcData = ActiveSheet.Name & "!" & Range("A1:BM30000").Address(ReferenceStyle:=xlR1C1)
' CREATION NOUVELLE FEUILLE
Set sht = Sheets.Add
sht.Name = "TCD"
' LOCALISATION TCD
StartPvt = sht.Name & "!" & sht.Range("A3").Address(ReferenceStyle:=xlR1C1)
' CREATION PIVOT CACHE
Set pvtCache = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=SrcData)
' CREATION TCD A PARTIR DU PIVOT CACHE
Set pvt = pvtCache.CreatePivotTable(TableDestination:=StartPvt, TableName:="PivotTable1")
' AJOUTER CHAMPS LIGNE
pvt.PivotFields("Article").Orientation = xlRowField
' AJOUTER CHAMPS COLONNE
pvt.PivotFields("suppliername").Orientation = xlColumnField
' AJOUTER CHAMPS VALEUR
pf = "Ordered ML"
pf_Name = "Somme Ordered"
pvt.AddDataField pvt.PivotFields("Ordered ML"), pf_Name, xlSum
' ENLEVER VIDE DES FILTRES
With Sheets("TCD").PivotTables("PivotTable1").PivotFields("Suppliername")
.PivotItems("(blank)").Visible = False
End With
End Sub
Configuration: Windows / Edge 18.17763
A voir également:
- Erreur d'execution '-2147417848' pivotcache
- Erreur 0x80070643 - Accueil - Windows
- Erreur 4201 france tv ✓ - Forum Réseaux sociaux
- Erreur 4101 france tv - Forum Lecteurs et supports vidéo
- J'aime par erreur facebook notification - Forum Facebook
- Code erreur f3500-31 ✓ - Forum Bbox Bouygues
Le problème venait de ma source mes données allaient jusqu'à la colonne AO et non BM du coup sans entête de colonne le TCD ne peut pas être créer.
Une fois ce détail corrigé, le code marche parfaitement.
Merci