Bonjour,
Petite question sur un code
J'ai fais une macro qui me fait des graphiques suivant certaines données d'un tableau
il fait bien le premier graphique mais je n'arrive pas le faire passer au second
en fait je voudrais surtout qu'il lise le code jusqu'au if , qu'il applique la solution adéquate et apres qu'il revienne au début pour poursuivre avec le second graphique et ainsi de suite.
Si quelqu'un a une idéee ?
Je vous remercie d'avance pour votre aide.
Petite question sur un code
J'ai fais une macro qui me fait des graphiques suivant certaines données d'un tableau
il fait bien le premier graphique mais je n'arrive pas le faire passer au second
Sub GraphLT()
'
Dim DR As Integer
Dim DC As Integer
Dim FR As Integer
Dim FC As Integer
début = InputBox("Semaine de départ de la période ", "Question")
fin = InputBox("Semaine de fin de la période", "question")
Columns("AE:AE").Select
Selection.Find(What:=début, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
DR = ActiveCell.Row
DC = ActiveCell.Column
Columns("AE:AE").Select
Selection.Find(What:=fin, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
FR = ActiveCell.Row
FC = ActiveCell.Column
For i = 1 To 19
x = Range("ae1").Offset(0, i)
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SeriesCollection(1).Values = "=Sheet2!R" & DR & "C" & DC + i & ":R" & FR & "C" & FC + i
ActiveChart.SeriesCollection(1).XValues = "=Sheet2!R" & DR & "c" & "31" & ":r" & FR & "c" & "31"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Values = "=Sheet2!R" & DR & "C" & DC & ":R" & FR & "C" & FC
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet2"
ActiveChart.HasDataTable = False
ActiveChart.ChartArea.Select
sonnom = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = x
End With
ActiveSheet.ChartObjects(sonnom).Activate
ActiveChart.ChartTitle.Select
Selection.AutoScaleFont = False
With Selection.Font
.Name = "Arial"
.FontStyle = "Gras"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveWindow.Visible = False
With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScale = 15
.MinorUnit = 1
.MajorUnit = 1
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveSheet.ChartObjects(sonnom).Activate
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = False
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.AutoScaleFont = False
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
With Selection.Border
.Weight = 1
.LineStyle = -1
.ColorIndex = 1
.Weight = xlThin
.LineStyle = xlContinuous
End With
ActiveSheet.ChartObjects(sonnom).Activate
ActiveChart.SeriesCollection(1).Select
With Selection
.MarkerBackgroundColorIndex = 1
.MarkerForegroundColorIndex = 1
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.Weight = 1
.LineStyle = -1
.ColorIndex = 1
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = 1
.MarkerForegroundColorIndex = 1
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
ActiveChart.ChartArea.Select
ActiveSheet.Shapes(sonnom).ScaleWidth 0.46, msoFalse, msoScaleFromTopLeft
ActiveSheet.Shapes(sonnom).ScaleHeight 0.5, msoFalse, msoScaleFromTopLeft
ActiveSheet.ChartObjects(sonnom).Activate
ActiveChart.Legend.Select
Selection.Delete
ActiveSheet.ChartObjects(sonnom).Activate
Selection.Interior.ColorIndex = xlNone
If i > 16 Then
ActiveChart.ChartArea.Select
ActiveSheet.ChartObjects(sonnom).Left = Range("A1").Offset(0, i + 5).Left
ActiveSheet.ChartObjects(sonnom).Top = Range("A1").Offset(i - 5, 0).Top
If i > 12 Then
ActiveChart.ChartArea.Select
ActiveSheet.ChartObjects(sonnom).Left = Range("A1").Offset(0, i + 4).Left
ActiveSheet.ChartObjects(sonnom).Top = Range("A1").Offset(i - 4, 0).Top
If i > 8 Then
ActiveChart.ChartArea.Select
ActiveSheet.ChartObjects(sonnom).Left = Range("A1").Offset(0, i + 3).Left
ActiveSheet.ChartObjects(sonnom).Top = Range("A1").Offset(i - 3, 0).Top
If i > 4 Then
ActiveChart.ChartArea.Select
ActiveSheet.ChartObjects(sonnom).Left = Range("A1").Offset(0, i + 2).Left
ActiveSheet.ChartObjects(sonnom).Top = Range("A1").Offset(i - 2, 0).Top
If i > 0 Then
ActiveChart.ChartArea.Select
ActiveSheet.ChartObjects(sonnom).Left = Range("A1").Offset(0, i + 1).Left
ActiveSheet.ChartObjects(sonnom).Top = Range("A1").Offset(i - 1, 0).Top
End If
Next i
ActiveWindow.Visible = False
End Sub
en fait je voudrais surtout qu'il lise le code jusqu'au if , qu'il applique la solution adéquate et apres qu'il revienne au début pour poursuivre avec le second graphique et ainsi de suite.
Si quelqu'un a une idéee ?
Je vous remercie d'avance pour votre aide.