Re : Fusion de cellules
Bon j'ai essayé quelque chose mais ca ne fonctionne pas...a priori excel genere des noms dynamiquement, du coup ma macro ne peut fonctionner...comment figé les noms pour que cette macro fonctionne?
Sub test3()
'
' test3 Macro
'
'ici selection de mon tableau entrée
NbLignes = ActiveSheet.UsedRange.Rows.Count
Range("A1:B" & NbLignes).Select
'ici TCD
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Etat des ventes!R1C1:R13C2", Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="Feuil2!R3C1", TableName:= _
"Tableau croisé dynamique", DefaultVersion:=xlPivotTableVersion10
Sheets("Feuil2").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("Tableau croisé dynamique").PivotFields("période" _
)
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("Tableau croisé dynamique").AddDataField ActiveSheet. _
PivotTables("Tableau croisé dynamique").PivotFields("Vente en euros"), _
"Somme de Vente en euros", xlSum
'création d'un graphique a partir du TCD
Columns("A:B").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Feuil5'!$A$3:$B$14")
ActiveWorkbook.ShowPivotChartActiveFields = True
ActiveChart.ChartType = xl3DColumnClustered
ActiveWorkbook.ShowPivotChartActiveFields = False
ActiveChart.ChartTitle.Select
ActiveSheet.ChartObjects("Graphique 3").Activate
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveSheet.ChartObjects("Graphique 3").Activate
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleRotated)
ActiveSheet.ChartObjects("Graphique 3").Activate
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Vente en euros"
ActiveSheet.ChartObjects("Graphique 3""").Activate
ActiveChart.ChartArea.Select
ActiveSheet.ChartObjects("Graphique 3").Activate
Selection.Cut
Sheets("Feuil5").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Feuil1").Select
Range("L12").Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("Graphique 1").Activate
End Sub