Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
calling a webservice | Excel Discussion (Misc queries) | |||
HELP!!!! Calling a sub from Workbook_BeforeSave | Excel Discussion (Misc queries) | |||
Calling Column D | Excel Discussion (Misc queries) | |||
Calling Column D | Excel Discussion (Misc queries) | |||
Calling an Add-In | Excel Discussion (Misc queries) |