Tableau croisé dynamique et graphique VB sous Excel

cs_audreyP Messages postés 1 Date d'inscription mardi 5 août 2008 Statut Membre Dernière intervention 7 août 2008 - 6 août 2008 à 09:24
youpiyoyo Messages postés 539 Date d'inscription vendredi 6 juin 2003 Statut Membre Dernière intervention 14 juillet 2010 - 6 août 2008 à 16:44
bonjour.
Je souhaite créer divers graphique. Afin de les faire, je
dois créer des tableaux croisé dynamique pour faire une synthèse des
données.
Je dispose des codes suivants:
Pour le tableau:

<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CAUDREY%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" /><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><style><!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 70.85pt 70.85pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --></style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->Sub TCD1()

'

' TCD1 Macro

 

'

    Range("A1:B13").Select

    Range(Selection, Selection.End(xlDown)).Select

    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _

        "Feuil2!R1C1:R1361C2").CreatePivotTable TableDestination:= _

        "[010808.xls]Feuil2!R23C4", TableName:="Tableau croisé dynamique3", _

        DefaultVersion:=xlPivotTableVersion10

    ActiveWorkbook.ShowPivotTableFieldList = True

    With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields( _

        "REGROUPEMENT 2")

        .Orientation = xlRowField

        .Position = 1

    End With

    ActiveSheet.PivotTables("Tableau croisé dynamique3").AddDataField ActiveSheet. _

        PivotTables("Tableau croisé dynamique3").PivotFields("Remb mutuelle"), _

        "Somme de Remb mutuelle", xlSum

End Sub

Pour le graphique voulu (avant de faire le tableau, effectué sur une plage fixe):
<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CAUDREY%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" /><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style><!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 70.85pt 70.85pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --></style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->Sub Macro2()

'

'

 

'

    Range("<st1:place w:st="on">K2</st1:place>:L8").Select

    Charts.Add

    ActiveChart.ChartType = xlPie

    ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("<st1:place w:st="on">K2</st1:place>:L8"), PlotBy:= _

        xlColumns

    ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"

    ActiveChart.SeriesCollection(1).Select

    ActiveChart.ChartArea.Select

    With ActiveChart

        .HasTitle = True

        .ChartTitle.Characters.Text = "Ventilation des remboursements GENERATION"

    End With

End Sub

Comment
faut-il que je fasse pour que la plage de données ne soit pas fixe? (au
niveau du nombre de ligne mais aussi du nombre de colonne)
Si je
créer un graphique depuis le TCD, il se met automatiquement dans une
nouvelle feuille. Faut-il faire un nouveau tableau égal a "copier -
valeur"?

Merci d'avance
AudreyP

1 réponse

youpiyoyo Messages postés 539 Date d'inscription vendredi 6 juin 2003 Statut Membre Dernière intervention 14 juillet 2010
6 août 2008 à 16:44
Salut,

essaye de le faire avec des plages nommées.

@+
youpi :)
0
Rejoignez-nous