Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 29th, 2006, 11:13 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default charts

i have some charts in a worksheet , and i want to show one of them when user select an item in combobox . means for each item of combobox one of the charts should be shown and the other should be hidden .
how can i show or hide a chart by vb code ?

Reply With Quote
  #2 (permalink)  
Old May 31st, 2006, 09:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I'm guessing these charts are embedded on the current worksheet rather than on separate tabs. If this is the case you can get all of the charts on a sheet by using the ChartObjects method on the worksheet object to return a collection. With this collection you can either loop through until you find the desired named Chart or you can skip straight to the desired one by specifying the known index number. Having got the ChartObject in question you just need to set the Visible property to True / False to hide and display. The following bit of code demonstrates the principle on the first Chart of Sheet1, amend sheet name / chart number as appropriate...

Code:
Sub Test()

Dim wb As Worksheet

    Set wb = ThisWorkbook.Sheets("Sheet1")

    wb.ChartObjects(1).Visible = False
    MsgBox "Hidden"

    wb.ChartObjects(1).Visible = True
    MsgBox "Visible"

End Sub
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
charts MunishBhatia ASP.NET 2.0 Professional 0 May 28th, 2007 11:52 AM
about charts MunishBhatia ASP.NET 2.0 Professional 1 May 11th, 2007 05:40 AM
Charts by VBA jaymur BOOK: Expert One-on-One Access Application Development 7 June 8th, 2006 12:59 AM
Crystal Charts Owens1013 BOOK: Professional Crystal Reports for VS.NET 0 September 20th, 2004 11:47 AM
Chapter 5 Charts jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 June 16th, 2004 09:52 AM



All times are GMT -4. The time now is 01:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.