petite modif de macro

gege21

XLDnaute Occasionnel
bonjours a tous

cette macro me crée un graphique
et je voudrai pouvoir régler certain paramètre du graph
donc pouvoir modifer les valeur en rouge dans la feuil config

la valeur -30 dans la cellule "k3" dans la feuil "config"
la valeur 10 dans la cellule "k5" dans la feuil "config"
la valeur 1240 dans la cellule "k7" dans la feuil "config"
la valeur 600 dans la cellule "k9" dans la feuil "config"

Code:
Sub graph_pluietotale_mini_maxi()
Dim F1 As Worksheet, F2 As Worksheet
Set F1 = Worksheets(Feuil3.Name)
Set F2 = Worksheets(Feuil6.Name)
Application.ScreenUpdating = False
On Error Resume Next
F2.Shapes("Graphique1").Delete
Charts.Add
With ActiveChart
    .ChartType = xlLine
    .SeriesCollection.NewSeries
    .SeriesCollection(1).XValues = F1.Range("A2", F1.[A2].End(xlDown))
    .SeriesCollection(1).Values = F1.Range("L2", F1.[L2].End(xlDown))
    .SeriesCollection(1).Name = F1.Range("L1")
    .Location Where:=xlLocationAsObject, Name:="graph.mini-maxi"
    End With
 ActiveSheet.ChartObjects("Graphique1").Activate
    ActiveChart.PlotArea.Select
    ActiveChart.Axes(xlValue).CrossesAt =[COLOR="Red"] -30[/COLOR]
    ActiveChart.Axes(xlCategory).TickLabelSpacing = [COLOR="Red"]10[/COLOR]
    ActiveChart.ChartTitle.Delete
    ActiveSheet.ChartObjects("Graphique1").Activate
    ActiveChart.ChartArea.Select
ActiveChart.Parent.Name = "Graphique1"
With ActiveSheet.Shapes("Graphique1")
    .Left = 0
    .Top = 0
    .Width = [COLOR="Red"]1240[/COLOR]
    .Height =[COLOR="Red"] 600[/COLOR]
End With
[A1].Select
End Sub

j'appaire avoir été claire dans mes explication
:rolleyes:
 

ROGER2327

XLDnaute Barbatruc
Re : petite modif de macro

Bonjour gege21
Peut-être comme ceci ?
Code:
[COLOR="DarkSlateGray"][B]Sub graph_pluietotale_mini_maxi()
Dim F1 As Worksheet, F2 As Worksheet
Set F1 = Worksheets(Feuil3.Name)
Set F2 = Worksheets(Feuil6.Name)
Application.ScreenUpdating = False
On Error Resume Next
F2.Shapes("Graphique1").Delete
Charts.Add
With ActiveChart
    .ChartType = xlLine
    .SeriesCollection.NewSeries
    .SeriesCollection(1).XValues = F1.Range("A2", F1.[A2].End(xlDown))
    .SeriesCollection(1).Values = F1.Range("L2", F1.[L2].End(xlDown))
    .SeriesCollection(1).Name = F1.Range("L1")
    .Location Where:=xlLocationAsObject, Name:="graph.mini-maxi"
    End With
 ActiveSheet.ChartObjects("Graphique1").Activate
    ActiveChart.PlotArea.Select
    ActiveChart.Axes(xlValue).CrossesAt = [COLOR="Red"]Worksheets("config").Range("K3").Value[/COLOR]
    ActiveChart.Axes(xlCategory).TickLabelSpacing =  [COLOR="Red"]Worksheets("config").Range("K5").Value[/COLOR]
    ActiveChart.ChartTitle.Delete
    ActiveSheet.ChartObjects("Graphique1").Activate
    ActiveChart.ChartArea.Select
ActiveChart.Parent.Name = "Graphique1"
With ActiveSheet.Shapes("Graphique1")
    .Left = 0
    .Top = 0
    .Width =  [COLOR="Red"]Worksheets("config").Range("K7").Value[/COLOR]
    .Height =  [COLOR="Red"]Worksheets("config").Range("K9").Value[/COLOR]
End With
[A1].Select
End Sub[/B][/COLOR]
ROGER2327
#3398


15 Floréal An CCXVIII
2010-W18-2T20:05:14Z
 

Statistiques des forums

Discussions
312 304
Messages
2 087 062
Membres
103 447
dernier inscrit
DamD