Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("A1:A2"), Target) is Nothing Then 'si modif de A1:A2 ...
'code
End If
End Sub
Je rebondis sur ce sujet qui fonctionne tres bien mais quand on a deux graphiques et que l'on veut piloter qu'un seul via des cellules on fait comment?Re : Modifier l'échelle d'un graph avec une macro ?
Bonjour
Voici un exemple
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Application.Intersect(Target, Range("b12:b15,c7:e7")) Is Nothing Then
ActiveSheet.ChartObjects(1).Activate
With ActiveChart
.Axes(xlValue).MinimumScale = Range("B12").Value
.Axes(xlValue).MaximumScale = Range("B13").Value
.Axes(xlCategory).MinimumScale = Range("B14").Value
.Axes(xlCategory).MaximumScale = Range("B15").Value
End With
End If
End Sub
Bonsoir
Il suffit de remplacer
ActiveSheet.ChartObjects(1).Activate
par
ActiveSheet.ChartObjects(2).Activate
Code:Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Not Application.Intersect(Target, Range("b12:b15,c7:e7")) Is Nothing Then ActiveSheet.ChartObjects(1).Activate With ActiveChart .Axes(xlValue).MinimumScale = Range("B12").Value .Axes(xlValue).MaximumScale = Range("B13").Value .Axes(xlCategory).MinimumScale = Range("B14").Value .Axes(xlCategory).MaximumScale = Range("B15").Value End With End If End Sub