MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Chart Code

Posted by Aaron on January 02, 2002 6:06 AM

I have three charts on three separate worksheets, and the ranges are all different. Is there and way to make this code specific to the chart and the worksheet the chart is on?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Worksheet("ActiveSheet.Name").ChartObjects(1).Chart(xlValue)
.MaximumScale = Worksheet("ActiveSheet.Name").Range("N11").Value
.MinimumScale = Worksheet("ActiveSheet.Name").Range("M11").Value
End With
End Sub

Posted by Bariloche on January 02, 2002 9:09 AM


I think this is what you want (assuming that this event code is in the chart code sheet:

MySheetName = ActiveSheet.Name

Then just use MySheetName thusly: Worksheet(MySheetName)