[VBA] clignottement de graphique VBA Excel

Résolu
Shinjitm Messages postés 13 Date d'inscription   Statut Membre Dernière intervention   -  
 Shinjitm -
Bonjour,

Je fais actuellement une macro Excel pour traiter automatiquement des données et finalement tracer un graphique les résumant. Cependant, lorsque ma macro exécute la partie "tracer du graphique", le graphe s'efface et se retrace à chaque nouvelle ligne, à chaque modification de paramètre, ce qui donne une sorte de clignottement vraiment insupportable. Je souhaiterais donc savoir si il y a un moyen, ou une ruse, pour éviter ce phénomène très désagréable.

D'avance merci





(...)

Charts.Add
ActiveChart.ChartType = xlXYScatterLinesNoMarkers '
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Courbe L1"
ActiveChart.Deselect

Charts("Courbe L1").PlotArea.Interior.ColorIndex = xlNone
With Charts("Courbe L1")
.HasTitle = True
.ChartTitle.Characters.Text = "Line voltage"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "PK (m)"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "U (V)"
End With
With Charts("Courbe L1").Axes(xlCategory)
.MinimumScale = 0
.MaximumScale = EchelleGraphique1
End With

Charts("Courbe L1").SetSourceData _
Source:=Range(Sheets("Tension L1").Cells(3, 1), Sheets("Tension L1").Cells(LigneActiveAL1 - 1, 2)), PlotBy:=xlColumns
Charts("Courbe L1").SeriesCollection(1).XValues = "='Tension L1'!R3C1:R" & LigneActiveAL1 - 1 & "C1"
Charts("Courbe L1").SeriesCollection(1).Values = "='Tension L1'!R3C2:R" & LigneActiveAL1 - 1 & "C2"
Charts("Courbe L1").SeriesCollection(1).Name = "=""Voie 1"""
Charts("Courbe L1").SeriesCollection.NewSeries
Charts("Courbe L1").SeriesCollection(2).XValues = "='Tension L1'!R3C4:R" & LigneActiveBL1 - 1 & "C4"
Charts("Courbe L1").SeriesCollection(2).Values = "='Tension L1'!R3C5:R" & LigneActiveBL1 - 1 & "C5"
Charts("Courbe L1").SeriesCollection(2).Name = "=""Voie 2"""
Charts("Courbe L1").SeriesCollection.NewSeries
Charts("Courbe L1").SeriesCollection(3).XValues = "='Tension L1'!R3C7:R" & PROK1 + 2 & "C7"
Charts("Courbe L1").SeriesCollection(3).Values = "='Tension L1'!R3C8:R" & PROK1 + 2 & "C8"
Charts("Courbe L1").SeriesCollection(3).Name = "=""PR"""
With Charts("Courbe L1").Legend.LegendEntries(3).LegendKey.Border
.Weight = xlThin
.LineStyle = xlNone
End With
With Charts("Courbe L1").Axes(xlValue)
.MinimumScale = 400
End With
With Charts("Courbe L1").Legend.LegendEntries(3).LegendKey
.MarkerBackgroundColorIndex = 1
.MarkerForegroundColorIndex = 1
.MarkerStyle = xlTriangle
.Smooth = False
.MarkerSize = 10
.Shadow = False
End With
If PRHS1 <> 0 Then
Charts("Courbe L1").SeriesCollection.NewSeries
Charts("Courbe L1").SeriesCollection(4).XValues = "='Tension L1'!R3C10:R" & PRHS1 + 2 & "C10"
Charts("Courbe L1").SeriesCollection(4).Values = "='Tension L1'!R3C11:R" & PRHS1 + 2 & "C11"
Charts("Courbe L1").SeriesCollection(4).Name = "=""PR en défaut"""
With ActiveChart.Legend.LegendEntries(4).LegendKey.Border
.Weight = xlThin
.LineStyle = xlNone
End With
With Charts("Courbe L1").Legend.LegendEntries(4).LegendKey
.MarkerBackgroundColorIndex = 3
.MarkerForegroundColorIndex = 3
.MarkerStyle = xlTriangle
.Smooth = False
.MarkerSize = 10
.Shadow = False
End With
End If
Sheets("Courbe L1").Move After:=Sheets("Tension L2")
ActiveWindow.Zoom = 100

(...)
A voir également:

1 réponse

pilas31 Messages postés 1825 Date d'inscription   Statut Contributeur Dernière intervention   645
 
Bonjour,

Oui il existe une instruction pour éviter la mise à jour des fenêtres pendant l'éxécution du code.
Il faut encadrer le code par les deux instructions suivantes :
Application.ScreenUpdating = False

' le code ....

Application.ScreenUpdating = True

A+
0
Shinjitm
 
Ca fonctionne ! merci beaucoup !
0