bonjours a tous
cette macro me cree un graphique
mais la les date sur l'axe des abcisse est faux et je ne c pas pourquoi
j'ai besoin de votre aide
cette macro me cree un graphique
mais la les date sur l'axe des abcisse est faux et je ne c pas pourquoi
j'ai besoin de votre aide
Code:
Sub moisTemps()
Sheets("graph.mesuel").Visible = True
Sheets("graph.mesuel").Select
Set F1 = Worksheets(Feuil11.Name)
Application.ScreenUpdating = False
On Error Resume Next
F1.Shapes("Graphique1").Delete
Dim Mois As Integer, Année As Long, Plage As Range, I As Integer
Select Case Sheets("menu").ComboBox1
Case "janvier"
Mois = 1
Case "février"
Mois = 2
Case "mars"
Mois = 3
Case "avril"
Mois = 4
Case "mai"
Mois = 5
Case "juin"
Mois = 6
Case "juillet"
Mois = 7
Case "août"
Mois = 8
Case "septembre"
Mois = 9
Case "octobre"
Mois = 10
Case "novembre"
Mois = 11
Case "décembre"
Mois = 12
Case Else
Exit Sub
End Select
Année = Sheets("menu").ComboBox2
If Année = 0 Then Exit Sub
With Sheets("Données")
I = 2
While .Cells(I, 1) <> ""
If Month(.Cells(I, 1)) = Mois And Year(.Cells(I, 1)) = Année Then
If Plage Is Nothing Then
Set Plage = Union(.Cells(I, 3), .Cells(I, 13)) ' colone
Else
Set Plage = Union(Plage, .Cells(I, 3), .Cells(I, 13)) ' colone
End If
End If
I = I + 1
Wend
End With
If Plage Is Nothing Then
MsgBox "Il n'y a pas de valeurs à cette date !", vbExclamation, "Erreur" _
: Sheets("menu").Visible = True: Sheets("menu").Select _
: Sheets("graph.mesuel").Visible = False
Exit Sub
End If
Charts.Add
With ActiveChart
.ChartType = xlLine
.SetSourceData Source:=Plage, PlotBy:=xlColumns
.Location Where:=xlLocationAsObject, Name:=F1.Name
End With
' réglage axe X du graphique
With ActiveChart
.PlotArea.Select
.Axes(xlValue).CrossesAt = -30
.Axes(xlCategory).TickLabelSpacing = 40
.Axes(xlCategory).TickMarkSpacing = 30
.SeriesCollection(1).Name = "='Données'!$c$1"
.SeriesCollection(2).Name = "='Données'!$m$1"
.ChartTitle.Delete
End With
' affiche date et heurs sur graphique
ActiveSheet.ChartObjects("Graphique1").Activate
ActiveChart.ChartArea.Select
derlin = Sheets("Données").Range("R1048576").End(xlUp).Row
ActiveChart.SeriesCollection(1).XValues = "='Données'!$R$2:$R$" & derlin
ActiveChart.Parent.Name = "Graphique1"
' réglage taille du graphique
With ActiveSheet.Shapes("Graphique1")
.Left = 0
.Top = 0
.Width = 1260
.Height = 750
End With
' couleur des courbes du graphique
Sheets("graph.mini-maxi").Select
ActiveSheet.ChartObjects("Graphique1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 0
.Weight = xlThin
.LineStyle = xlContinuous
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Border
.ColorIndex = 20
.Weight = xlThin
.LineStyle = xlContinuous
End With
ActiveChart.ChartArea.Select
End Sub