![]() |
CALLING PARTICULAR CHARTS
I have this code that allows me to change the scaling of ALL charts from
specified cells I have set up. Is there a way that instead of changing all charts that I can pick a couple particular charts instead. For instance if I have 10 charts and I just want to rescale charts:2,5,6 and 9 Private Sub Worksheet_Change(ByVal Target As Range) For iChart = 1 To ActiveSheet.ChartObjects.Count Set cht = ActiveSheet.ChartObjects(iChart).Chart With cht.Axes(xlValue) .MinimumScale = ActiveSheet.Range("B24") .MaximumScale = ActiveSheet.Range("B23") End With With cht.Axes(xlCategory) .MinimumScale = ActiveSheet.Range("C24") .MaximumScale = ActiveSheet.Range("C23") End With Next End Sub |
CALLING PARTICULAR CHARTS
Hi,
Try this, which will reference the specified chart indexes and only run when the cells B23:C24 are changed. Private Sub Worksheet_Change(ByVal Target As Range) Dim iChart Dim cht If Not Intersect(Target, Range("B23:C24")) Is Nothing Then For Each iChart In Array(2, 5, 6, 9) Set cht = ActiveSheet.ChartObjects(iChart).Chart With cht.Axes(xlValue) .MinimumScale = ActiveSheet.Range("B24") .MaximumScale = ActiveSheet.Range("B23") End With With cht.Axes(xlCategory) .MinimumScale = ActiveSheet.Range("C24") .MaximumScale = ActiveSheet.Range("C23") End With Next End If End Sub Cheers Andy Jase wrote: I have this code that allows me to change the scaling of ALL charts from specified cells I have set up. Is there a way that instead of changing all charts that I can pick a couple particular charts instead. For instance if I have 10 charts and I just want to rescale charts:2,5,6 and 9 Private Sub Worksheet_Change(ByVal Target As Range) For iChart = 1 To ActiveSheet.ChartObjects.Count Set cht = ActiveSheet.ChartObjects(iChart).Chart With cht.Axes(xlValue) .MinimumScale = ActiveSheet.Range("B24") .MaximumScale = ActiveSheet.Range("B23") End With With cht.Axes(xlCategory) .MinimumScale = ActiveSheet.Range("C24") .MaximumScale = ActiveSheet.Range("C23") End With Next End Sub -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
All times are GMT +1. The time now is 03:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com