petite modif de macro

  • Initiateur de la discussion Initiateur de la discussion gege21
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

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
🙄
 
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
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
1
Affichages
475
Réponses
0
Affichages
387
Réponses
7
Affichages
558
Retour