Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 117
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,489
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling a webservice Jörgen Excel Discussion (Misc queries) 0 January 1st 08 06:44 PM
HELP!!!! Calling a sub from Workbook_BeforeSave RocketMan[_2_] Excel Discussion (Misc queries) 4 May 31st 07 11:47 PM
Calling Column D Stefi Excel Discussion (Misc queries) 0 November 30th 06 02:31 PM
Calling Column D Trackeous Excel Discussion (Misc queries) 0 November 30th 06 02:17 PM
Calling an Add-In BillCPA Excel Discussion (Misc queries) 2 August 11th 05 09:32 PM


All times are GMT +1. The time now is 04:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"