Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Loop through charts

I have a situation where I would like to loop through all the charts on a
sheet and if a condition is true, hide them.
Can't get it right though!

My attempt - in Sheet_Activate

Dim ch as Chart
If Range("D9").value=0 then
For each ch In Sheets("MySheet")
ch.Visible=False
Next
Else
......................
End If

Sandy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Loop through charts

Sandy,

Charts that reside on a worksheet (rather than being Chart Sheets) are
wrapped on in a ChartObject object. One child of the ChartObject object is
the Chart object. Try something like:

Dim ChtObj As ChartObject
For Each ChtObj In Worksheets(1).ChartObjects
Debug.Print ChtObj.Name, ChtObj.Chart.Name
Next ChtObj


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Sandy" wrote in message
...
I have a situation where I would like to loop through all the charts on a
sheet and if a condition is true, hide them.
Can't get it right though!

My attempt - in Sheet_Activate

Dim ch as Chart
If Range("D9").value=0 then
For each ch In Sheets("MySheet")
ch.Visible=False
Next
Else
......................
End If

Sandy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Loop through charts

Thank you very much Chip - Perfect
Sandy

"Chip Pearson" wrote in message
...
Sandy,

Charts that reside on a worksheet (rather than being Chart Sheets) are
wrapped on in a ChartObject object. One child of the ChartObject object is
the Chart object. Try something like:

Dim ChtObj As ChartObject
For Each ChtObj In Worksheets(1).ChartObjects
Debug.Print ChtObj.Name, ChtObj.Chart.Name
Next ChtObj


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Sandy" wrote in message
...
I have a situation where I would like to loop through all the charts on a
sheet and if a condition is true, hide them.
Can't get it right though!

My attempt - in Sheet_Activate

Dim ch as Chart
If Range("D9").value=0 then
For each ch In Sheets("MySheet")
ch.Visible=False
Next
Else
......................
End If

Sandy


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
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Loop to create charts Lance Hoffmeyer[_3_] Excel Programming 1 May 29th 07 07:46 PM
Use a loop to create multiple Charts - Suggestions ? APOEL Charts and Charting in Excel 1 July 29th 06 03:36 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Loop through sheets, deselect charts Daniel Bonallack[_2_] Excel Programming 4 October 28th 03 07:27 PM


All times are GMT +1. The time now is 11:54 PM.

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"