Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 29th, 2006, 11:13 PM
Registered User
 
Join Date: May 2006
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 ?

 
Old May 31st, 2006, 09:53 AM
Friend of Wrox
 
Join Date: Jun 2003
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





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





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