Je crée un TCD contenant des champs calculés avec VBA. Ensuite, je souhaite
changer une partie des pivotfields (notamment des champs calculés) et là,
cela plante.
Si ce n'est pas un champs calculé, un pivotfield.orientation =xlhidden
marche masi si c'en est un, impossible ! Pourtant si je demande à
l'enregistreur de macro, il me sort la même chose...
Si vous voyez ou est le problème, surtout n'hésitez pas :-)
With ActiveSheet.PivotTables("PivotTable2")
.PivotFields("Sum of Cost of sales").Orientation = xlHidden
'.PivotFields("Sum of GM").Orientation = xlHidden
'.PivotFields("Sum of GM in %").Orientation = xlHidden
'.PivotFields("Sum of CPU").Orientation = xlHidden
'Les 3 lignes plantent...Ce n'est pas le with, déjà testé lol
end with
end sub
Function make_fields(field As String, position As Integer, style As String,
pivotname As String)
With ActiveSheet.PivotTables(pivotname).PivotFields(field)
.Orientation = xlDataField
.NumberFormat = style
.Function = xlSum
.position = position
End With
make_fields = position + 1
With ActiveSheet.PivotTables("PivotTable2") .PivotFields("Sum of NR").Orientation = xlHidden .PivotFields("Sum of GM").Orientation = xlHidden
End With
End Sub Function make_fields(field As String, position As Integer, style As String, pivotname As String) With ActiveSheet.PivotTables(pivotname).PivotFields(field) .Orientation = xlDataField .NumberFormat = style .Function = xlSum .position = position End With make_fields = position + 1
End Function
Comment peut on le retirer ? Cordialement Benjamin
Bonjour,
Je crée un TCD contenant des champs calculés avec VBA. Ensuite, je souhaite changer une partie des pivotfields (notamment des champs calculés) et là, cela plante.
Si ce n'est pas un champs calculé, un pivotfield.orientation =xlhidden marche masi si c'en est un, impossible ! Pourtant si je demande à l'enregistreur de macro, il me sort la même chose...
Si vous voyez ou est le problème, surtout n'hésitez pas :-)
With ActiveSheet.PivotTables("PivotTable2") .PivotFields("Sum of Cost of sales").Orientation = xlHidden '.PivotFields("Sum of GM").Orientation = xlHidden '.PivotFields("Sum of GM in %").Orientation = xlHidden '.PivotFields("Sum of CPU").Orientation = xlHidden 'Les 3 lignes plantent...Ce n'est pas le with, déjà testé lol end with
end sub
Function make_fields(field As String, position As Integer, style As String, pivotname As String) With ActiveSheet.PivotTables(pivotname).PivotFields(field) .Orientation = xlDataField .NumberFormat = style .Function = xlSum .position = position End With make_fields = position + 1
End Function
Merci d'avance à tous Cordialement Benjamin
Ooops j'ai oublié le champ NR ainsi que de calculer les champs calculés lol
bon on simplifie :
voila en sheet 1 j'ai
A B
1 NR COS
2 100 50
3 150 70
et le code suivant qui plante quand je veux retirer GM :
With ActiveSheet.PivotTables("PivotTable2")
.PivotFields("Sum of NR").Orientation = xlHidden
.PivotFields("Sum of GM").Orientation = xlHidden
End With
End Sub
Function make_fields(field As String, position As Integer, style As String,
pivotname As String)
With ActiveSheet.PivotTables(pivotname).PivotFields(field)
.Orientation = xlDataField
.NumberFormat = style
.Function = xlSum
.position = position
End With
make_fields = position + 1
End Function
Comment peut on le retirer ?
Cordialement
Benjamin
Bonjour,
Je crée un TCD contenant des champs calculés avec VBA. Ensuite, je souhaite
changer une partie des pivotfields (notamment des champs calculés) et là,
cela plante.
Si ce n'est pas un champs calculé, un pivotfield.orientation =xlhidden
marche masi si c'en est un, impossible ! Pourtant si je demande à
l'enregistreur de macro, il me sort la même chose...
Si vous voyez ou est le problème, surtout n'hésitez pas :-)
With ActiveSheet.PivotTables("PivotTable2")
.PivotFields("Sum of Cost of sales").Orientation = xlHidden
'.PivotFields("Sum of GM").Orientation = xlHidden
'.PivotFields("Sum of GM in %").Orientation = xlHidden
'.PivotFields("Sum of CPU").Orientation = xlHidden
'Les 3 lignes plantent...Ce n'est pas le with, déjà testé lol
end with
end sub
Function make_fields(field As String, position As Integer, style As String,
pivotname As String)
With ActiveSheet.PivotTables(pivotname).PivotFields(field)
.Orientation = xlDataField
.NumberFormat = style
.Function = xlSum
.position = position
End With
make_fields = position + 1
With ActiveSheet.PivotTables("PivotTable2") .PivotFields("Sum of NR").Orientation = xlHidden .PivotFields("Sum of GM").Orientation = xlHidden
End With
End Sub Function make_fields(field As String, position As Integer, style As String, pivotname As String) With ActiveSheet.PivotTables(pivotname).PivotFields(field) .Orientation = xlDataField .NumberFormat = style .Function = xlSum .position = position End With make_fields = position + 1
End Function
Comment peut on le retirer ? Cordialement Benjamin
Bonjour,
Je crée un TCD contenant des champs calculés avec VBA. Ensuite, je souhaite changer une partie des pivotfields (notamment des champs calculés) et là, cela plante.
Si ce n'est pas un champs calculé, un pivotfield.orientation =xlhidden marche masi si c'en est un, impossible ! Pourtant si je demande à l'enregistreur de macro, il me sort la même chose...
Si vous voyez ou est le problème, surtout n'hésitez pas :-)
With ActiveSheet.PivotTables("PivotTable2") .PivotFields("Sum of Cost of sales").Orientation = xlHidden '.PivotFields("Sum of GM").Orientation = xlHidden '.PivotFields("Sum of GM in %").Orientation = xlHidden '.PivotFields("Sum of CPU").Orientation = xlHidden 'Les 3 lignes plantent...Ce n'est pas le with, déjà testé lol end with
end sub
Function make_fields(field As String, position As Integer, style As String, pivotname As String) With ActiveSheet.PivotTables(pivotname).PivotFields(field) .Orientation = xlDataField .NumberFormat = style .Function = xlSum .position = position End With make_fields = position + 1