Link embedded chart to a commandbutton?

I have a embedded chart which I wish to show the chart when I press a 
commandButton and hide the chart when I press either the same button or 
another one.
-- 
Bob
0
Bob4289 (354)
6/16/2009 9:23:02 AM
excel.charting 18370 articles. 0 followers. Follow

7 Replies
619 Views

Similar Articles

[PageSpeed] 18

Hi,

The basic code would be, which will toggle visibility of first chartobject 
on sheet.

Sub Button2_Click()

    ActiveSheet.ChartObjects(1).Visible = Not 
ActiveSheet.ChartObjects(1).Visible

End Sub

Cheers
Andy

-- 

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Bob" <Bob@discussions.microsoft.com> wrote in message 
news:F16B6F66-95AB-4C12-9B21-B5513FB1FDEE@microsoft.com...
>I have a embedded chart which I wish to show the chart when I press a
> commandButton and hide the chart when I press either the same button or
> another one.
> -- 
> Bob 

0
andy9699 (3616)
6/16/2009 10:07:06 AM
Many thanks Andy, I shall try that out on friday when i am back at work
-- 
Bob


"Andy Pope" wrote:

> Hi,
> 
> The basic code would be, which will toggle visibility of first chartobject 
> on sheet.
> 
> Sub Button2_Click()
> 
>     ActiveSheet.ChartObjects(1).Visible = Not 
> ActiveSheet.ChartObjects(1).Visible
> 
> End Sub
> 
> Cheers
> Andy
> 
> -- 
> 
> Andy Pope, Microsoft MVP - Excel
> http://www.andypope.info
> "Bob" <Bob@discussions.microsoft.com> wrote in message 
> news:F16B6F66-95AB-4C12-9B21-B5513FB1FDEE@microsoft.com...
> >I have a embedded chart which I wish to show the chart when I press a
> > commandButton and hide the chart when I press either the same button or
> > another one.
> > -- 
> > Bob 
> 
> 
0
Bob4289 (354)
6/16/2009 10:08:01 PM
Andy,
Tried it and I get a syntax error message
-- 
Bob


"Bob" wrote:

> Many thanks Andy, I shall try that out on friday when i am back at work
> -- 
> Bob
> 
> 
> "Andy Pope" wrote:
> 
> > Hi,
> > 
> > The basic code would be, which will toggle visibility of first chartobject 
> > on sheet.
> > 
> > Sub Button2_Click()
> > 
> >     ActiveSheet.ChartObjects(1).Visible = Not 
> > ActiveSheet.ChartObjects(1).Visible
> > 
> > End Sub
> > 
> > Cheers
> > Andy
> > 
> > -- 
> > 
> > Andy Pope, Microsoft MVP - Excel
> > http://www.andypope.info
> > "Bob" <Bob@discussions.microsoft.com> wrote in message 
> > news:F16B6F66-95AB-4C12-9B21-B5513FB1FDEE@microsoft.com...
> > >I have a embedded chart which I wish to show the chart when I press a
> > > commandButton and hide the chart when I press either the same button or
> > > another one.
> > > -- 
> > > Bob 
> > 
> > 
0
Bob4289 (354)
6/19/2009 7:32:01 AM
Probably because of the email formatting.

The syntax should be on 1 line.

Sub Button2_Click()

     ActiveSheet.ChartObjects(1).Visible = _
        Not  ActiveSheet.ChartObjects(1).Visible
 End Sub

Cheers
Andy
-- 

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Bob" <Bob@discussions.microsoft.com> wrote in message 
news:5E3AD1B2-57C9-448A-B417-CB35595101F7@microsoft.com...
> Andy,
> Tried it and I get a syntax error message
> -- 
> Bob
>
>
> "Bob" wrote:
>
>> Many thanks Andy, I shall try that out on friday when i am back at work
>> -- 
>> Bob
>>
>>
>> "Andy Pope" wrote:
>>
>> > Hi,
>> >
>> > The basic code would be, which will toggle visibility of first 
>> > chartobject
>> > on sheet.
>> >
>> > Sub Button2_Click()
>> >
>> >     ActiveSheet.ChartObjects(1).Visible = Not
>> > ActiveSheet.ChartObjects(1).Visible
>> >
>> > End Sub
>> >
>> > Cheers
>> > Andy
>> >
>> > -- 
>> >
>> > Andy Pope, Microsoft MVP - Excel
>> > http://www.andypope.info
>> > "Bob" <Bob@discussions.microsoft.com> wrote in message
>> > news:F16B6F66-95AB-4C12-9B21-B5513FB1FDEE@microsoft.com...
>> > >I have a embedded chart which I wish to show the chart when I press a
>> > > commandButton and hide the chart when I press either the same button 
>> > > or
>> > > another one.
>> > > -- 
>> > > Bob
>> >
>> > 

0
andy9699 (3616)
6/19/2009 8:11:04 AM
Andy thanks for that.
At the moment when I press the commanbutton(3) I can see the chart 
underneath the active page?
-- 
Bob


"Andy Pope" wrote:

> Probably because of the email formatting.
> 
> The syntax should be on 1 line.
> 
> Sub Button2_Click()
> 
>      ActiveSheet.ChartObjects(1).Visible = _
>         Not  ActiveSheet.ChartObjects(1).Visible
>  End Sub
> 
> Cheers
> Andy
> -- 
> 
> Andy Pope, Microsoft MVP - Excel
> http://www.andypope.info
> "Bob" <Bob@discussions.microsoft.com> wrote in message 
> news:5E3AD1B2-57C9-448A-B417-CB35595101F7@microsoft.com...
> > Andy,
> > Tried it and I get a syntax error message
> > -- 
> > Bob
> >
> >
> > "Bob" wrote:
> >
> >> Many thanks Andy, I shall try that out on friday when i am back at work
> >> -- 
> >> Bob
> >>
> >>
> >> "Andy Pope" wrote:
> >>
> >> > Hi,
> >> >
> >> > The basic code would be, which will toggle visibility of first 
> >> > chartobject
> >> > on sheet.
> >> >
> >> > Sub Button2_Click()
> >> >
> >> >     ActiveSheet.ChartObjects(1).Visible = Not
> >> > ActiveSheet.ChartObjects(1).Visible
> >> >
> >> > End Sub
> >> >
> >> > Cheers
> >> > Andy
> >> >
> >> > -- 
> >> >
> >> > Andy Pope, Microsoft MVP - Excel
> >> > http://www.andypope.info
> >> > "Bob" <Bob@discussions.microsoft.com> wrote in message
> >> > news:F16B6F66-95AB-4C12-9B21-B5513FB1FDEE@microsoft.com...
> >> > >I have a embedded chart which I wish to show the chart when I press a
> >> > > commandButton and hide the chart when I press either the same button 
> >> > > or
> >> > > another one.
> >> > > -- 
> >> > > Bob
> >> >
> >> > 
> 
> 
0
Bob4289 (354)
6/19/2009 10:19:01 AM
Sorry I don't understand what you mean?

On a worksheet enter 1,2,3 in cells A1:A3
Select A1:A3 and insert a chart on to the worksheet.
Using the Forms toolbar add a button to the worksheet.
Right click the button and assign macro.

The code should be in a standard code module.

Cheers
Andy

-- 

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Bob" <Bob@discussions.microsoft.com> wrote in message 
news:3D255DA0-D9BA-458F-8F02-8FF37841BB0A@microsoft.com...
> Andy thanks for that.
> At the moment when I press the commanbutton(3) I can see the chart
> underneath the active page?
> -- 
> Bob
>
>
> "Andy Pope" wrote:
>
>> Probably because of the email formatting.
>>
>> The syntax should be on 1 line.
>>
>> Sub Button2_Click()
>>
>>      ActiveSheet.ChartObjects(1).Visible = _
>>         Not  ActiveSheet.ChartObjects(1).Visible
>>  End Sub
>>
>> Cheers
>> Andy
>> -- 
>>
>> Andy Pope, Microsoft MVP - Excel
>> http://www.andypope.info
>> "Bob" <Bob@discussions.microsoft.com> wrote in message
>> news:5E3AD1B2-57C9-448A-B417-CB35595101F7@microsoft.com...
>> > Andy,
>> > Tried it and I get a syntax error message
>> > -- 
>> > Bob
>> >
>> >
>> > "Bob" wrote:
>> >
>> >> Many thanks Andy, I shall try that out on friday when i am back at 
>> >> work
>> >> -- 
>> >> Bob
>> >>
>> >>
>> >> "Andy Pope" wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > The basic code would be, which will toggle visibility of first
>> >> > chartobject
>> >> > on sheet.
>> >> >
>> >> > Sub Button2_Click()
>> >> >
>> >> >     ActiveSheet.ChartObjects(1).Visible = Not
>> >> > ActiveSheet.ChartObjects(1).Visible
>> >> >
>> >> > End Sub
>> >> >
>> >> > Cheers
>> >> > Andy
>> >> >
>> >> > -- 
>> >> >
>> >> > Andy Pope, Microsoft MVP - Excel
>> >> > http://www.andypope.info
>> >> > "Bob" <Bob@discussions.microsoft.com> wrote in message
>> >> > news:F16B6F66-95AB-4C12-9B21-B5513FB1FDEE@microsoft.com...
>> >> > >I have a embedded chart which I wish to show the chart when I press 
>> >> > >a
>> >> > > commandButton and hide the chart when I press either the same 
>> >> > > button
>> >> > > or
>> >> > > another one.
>> >> > > -- 
>> >> > > Bob
>> >> >
>> >> >
>>
>> 

0
andy9699 (3616)
6/19/2009 10:45:55 AM
Andy,
I works well now Thanks very much
-- 
Bob


"Andy Pope" wrote:

> Sorry I don't understand what you mean?
> 
> On a worksheet enter 1,2,3 in cells A1:A3
> Select A1:A3 and insert a chart on to the worksheet.
> Using the Forms toolbar add a button to the worksheet.
> Right click the button and assign macro.
> 
> The code should be in a standard code module.
> 
> Cheers
> Andy
> 
> -- 
> 
> Andy Pope, Microsoft MVP - Excel
> http://www.andypope.info
> "Bob" <Bob@discussions.microsoft.com> wrote in message 
> news:3D255DA0-D9BA-458F-8F02-8FF37841BB0A@microsoft.com...
> > Andy thanks for that.
> > At the moment when I press the commanbutton(3) I can see the chart
> > underneath the active page?
> > -- 
> > Bob
> >
> >
> > "Andy Pope" wrote:
> >
> >> Probably because of the email formatting.
> >>
> >> The syntax should be on 1 line.
> >>
> >> Sub Button2_Click()
> >>
> >>      ActiveSheet.ChartObjects(1).Visible = _
> >>         Not  ActiveSheet.ChartObjects(1).Visible
> >>  End Sub
> >>
> >> Cheers
> >> Andy
> >> -- 
> >>
> >> Andy Pope, Microsoft MVP - Excel
> >> http://www.andypope.info
> >> "Bob" <Bob@discussions.microsoft.com> wrote in message
> >> news:5E3AD1B2-57C9-448A-B417-CB35595101F7@microsoft.com...
> >> > Andy,
> >> > Tried it and I get a syntax error message
> >> > -- 
> >> > Bob
> >> >
> >> >
> >> > "Bob" wrote:
> >> >
> >> >> Many thanks Andy, I shall try that out on friday when i am back at 
> >> >> work
> >> >> -- 
> >> >> Bob
> >> >>
> >> >>
> >> >> "Andy Pope" wrote:
> >> >>
> >> >> > Hi,
> >> >> >
> >> >> > The basic code would be, which will toggle visibility of first
> >> >> > chartobject
> >> >> > on sheet.
> >> >> >
> >> >> > Sub Button2_Click()
> >> >> >
> >> >> >     ActiveSheet.ChartObjects(1).Visible = Not
> >> >> > ActiveSheet.ChartObjects(1).Visible
> >> >> >
> >> >> > End Sub
> >> >> >
> >> >> > Cheers
> >> >> > Andy
> >> >> >
> >> >> > -- 
> >> >> >
> >> >> > Andy Pope, Microsoft MVP - Excel
> >> >> > http://www.andypope.info
> >> >> > "Bob" <Bob@discussions.microsoft.com> wrote in message
> >> >> > news:F16B6F66-95AB-4C12-9B21-B5513FB1FDEE@microsoft.com...
> >> >> > >I have a embedded chart which I wish to show the chart when I press 
> >> >> > >a
> >> >> > > commandButton and hide the chart when I press either the same 
> >> >> > > button
> >> >> > > or
> >> >> > > another one.
> >> >> > > -- 
> >> >> > > Bob
> >> >> >
> >> >> >
> >>
> >> 
> 
> 
0
Bob4289 (354)
6/19/2009 1:01:01 PM
Reply:

Similar Artilces:

Deleting "hidden" charts on a worksheet
Hi everyone, I've been playing around w/ a worksheet that contains data and charts, inserting and removing multiple rows at a time. Unfortunately, I did not change the properties of the charts and they were all set to "Move and Size w/ Cells". When I deleted a series of rows, these charts disappeared and left a line across the spreadsheet where they used to be. I've tried everything to get rid of them (because they are now calculating incorrectly and giving me error messages), including deleting the rows where they appear, trying to select them on the sheet, but nothing w...

Pivot chart and Total row
Hi All I have a Pivot table and attached Pivot chart (all good so far). However, there are three columns (drop column details here) which are the two columns of data and a grand total column (showing the average of my two data columns) When I turn it into a pivot chart it does not display the grand total column as well (is there a way to do this). I have tried to go into the chart options but these are locked. I can copy and paste the results but this is a bit clumsy. Any suggestions - any help greatly appreciated Kind regards Rexmann PS using excel 2003 ...

linking with mfc42.lib and mfc90.lib?
Hallo! We have an old application we are porting using Visual Studio 2008. Originally developed with VC6.0. It's a mfc-applikation and thus referers to mfc90.lib. Together with the old application we've linked mfc42.lib. Additionally we have linked in a library we don't have the source to. This lib refers to mfc42.lib. Question: can we link in both mfc42.lib and mfc90.lib? Regards Goran This is a serious problem. The answer is, probably not, but "it depends". If the old library does not involve CStrings, if it does not use CWnd *, does not allocate MFC object...

How do I delete chart superimposed on Excel document?
Created Excel document. Print preview did not show gridlines. In attempting to get gridlines, somehow got into charts. A chart was created and is superimposed on original document. How do I get rid of the chart? How do I get gridlines on to original document? Oz Right-click on the chart and Edit>Clear>All To print gridlines.................File>Page Setup>Sheet Check "gridlines" and uncheck "draft quality". Gord Dibben MS Excel MVP On Fri, 4 Aug 2006 14:27:01 -0700, Oz Osborn <Oz Osborn@discussions.microsoft.com> wrote: >Created Excel docume...

Embedding Word table in Excel cell
Is there any way in which I can embed a small MS Word table in an Excel cell? Thanks. -- Larry Lester Copy / paste as a picture. Pictures can always be re-sized and re-positioned -- Gary's Student "Larry Lester" wrote: > Is there any way in which I can embed a small MS Word table in an Excel cell? > Thanks. > -- > Larry Lester Gary's reply works for pasting the table in as a graphic object _on_ an XL sheet, but you cannot paste a graphic into a cell as cell content. If you simply Paste to a cell, the corresponding number of cells will be filled with th...

Chart: range info from seriescollection?
I would like to fill a combobox (Rowsource) with data that are used in for instance the XValues or Values of a Seriescollection of a graph. "ActiveChart.SeriesCollection(1).Values" does not give the right type (I was hoping for a string type of info like "Sheet1.Range(a1:a10)"). How to get a Range to be used as Rowsource for my combobox??? Thanks for your suggestions, JB The Values and XValues will return an array of values. To get the range address like this, you will need to parse the series formula. Or you could use John Walkenbach's class module for extractin...

Is it possible to save an excel chart as .emf?
I would like to save an excel chart as .emf instead of .jpeg or .gif using the script below. Is this possible? Sub SaveChartAsGIF () Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif" ActiveChart.Export FileName:=Fname, FilterName:="GIF" End Sub ...

Step change charts
Help, I am trying to create a bar charts by year but only want to show increases and decreases through the middle years as step changes i.e. 1999 100 2000 +10 2001 -30 2002 +40 2003 120 How can I do this? What I should see is the first vertical bar being 100 then from the 100 level an increase of 10 to get to 110 then a decrease bar of -30 (from the 110 level) to get to 80 etc etc. For a tutorial, see the Excel | Charts | Waterfall Chart page of my web site. -- Regards, Tushar Mehta, MS MVP -- Excel www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Cus...

Excel Bar Chart with many elements Example
I am working with a survey database where one field represents one question in the Survey. Some questions allow the user to enter multiple answers. This data isn't normalized but I have t work with what I've got. Anyway I tried to create a chart in Acces with the wizard but got the error: "Cannot have more than elements in the chart". Anyway I attempted to recreate the char in Excel but my chart looks crammed and canno print entirely within one page. Does anyone know how or have a example of how to create a bar chart with many elements in a clea and consice manner T...

Can no longer cut/paste ranges in chart "edit data" fields?
In Excel 2007 I can no longer cut/paste cell ranges into the x and y datasets using the edit data tool. Is there a way to turn this back on? Also the chart range resets itself to the current length of the data, however, in many instances I want to set an exact future range. Is there a way to have excel not reset the range to what it "thinks" I want. > In Excel 2007 I can no longer cut/paste cell ranges into the x and y > datasets > using the edit data tool. Is there a way to turn this back on? I have no problem doing what you can't. Could you provide more det...

bad links
I did some formulas with figuers from other files. the problem is that when i open the sheet the links to the other documents don't work anymore. i have to open the source sheets so that the figuers appear. how can i make the links work even if the source sheets are not opend??? Thx, Ovidiu In the file that contains the Links, go to Edit>Links & you should find what you need. HTH |:>) "ovidiu" wrote: > I did some formulas with figuers from other files. the problem is that when i > open the sheet the links to the other documents don't work anymore. i ...

Need to send link with parameter
Hi , i got the following question, i'm doing mailing internally on my company and sometimes i need to send a link to a specific program passing a parameter to that file.and example will be (c:\ListMaker\Lister.exe -v -x), how can i pass a link like this?? if i do HTML on the mail like the following line: <a href ='file://c:\c:\ListMaker\Lister.exe -v -x'>Link<a> it will give me that the file is invalid... Any ideas. Thanks in advance. Alex. Alejandro K. <AleK@AleK.com> wrote: > if > i do HTML on the mail like the following line: > <a href ='...

Linking comments
Is there any way to link comments from once cell to another. When you link the contents of one cell to another, is there anyway to capture the comments as well. How about a userdefined function: Option Explicit Function EchoComment(FCell As Range) As Variant Application.Volatile With Application.Caller If .Comment Is Nothing Then 'do nothing Else .Comment.Delete End If If FCell.Comment Is Nothing Then 'do nothing Else .AddComment Text:=FCell.Comment.Text End If End...

can not see chart
I created a simple chart. For some odd reason the chart is all gray. I can only see the chart if i select the chart object. Please help! Thank you! Hi, Via the menus Tools > Options. On the View tab select Obejcts Show All. Cheers Andy Nick wrote: > I created a simple chart. For some odd reason the chart is all gray. I can > only see the chart if i select the chart object. Please help! Thank you! -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...

How to avoid when linked source data is changed, chart turns blan.
When I created new charts in Excel 2003, each previous chart became blank. Therefor I saved the file unter a new name and copied the previous chart to the new file. This created ofcourse links to the other files. Now I want to change the source file, but when I do that the chart becomes blank as well. Anybody who had this problem before and found out how to solve it ? Rgds, Chris ...

Can't open URL link from within Outlook
Attempting to click a URL link in an Outlook email results in simply opening IE with a blank page. This happens with all types of URLs (.us,.biz. .gov, etc). If the URL is manually entered into IE, everything works OK. Any ideas? Thanks ...

chart type keeps changing
My chart is "embedded" in my worksheet. The worksheet has months across the top in one row and net income per share in a row below it for each corresponding month. The x-axis is pulling data for the month and year eg. Jan-04...Feb-06. The y-axis is pulling data from a different row for the net income for each month. The chart has been maintained since Jan-04. It is a standard clustered column w/ a 3-D visual effect. I am trying to enter data for March '06 in data source, series one. I am updating the series 1 with the new column address that represents the new month eg...

opening links in html email
Office 2000 now won't open page links in html-formatted emails, even with <ctrl> held. Links written in plain text emails will open. Any help with settings to change or any workarounds? -- manfred ...

Dynamic Bar Chart Category Axis Problem
Hi I have created a dynamic bar chart, roughly based on Stephen Bullen's funchrt4. The number of categories can range from 2 to about 50 and ideally I would like the category axis names font to be Arial 10 at least. When the number of categories gets towards 50, the category axis names disappear altogether and the only way I have found to retrieve them is to manually reduce the font size to about 7 (dependent on the level of the zoom). This font size is excessively small for the majority of charts. Is there any way to get Excel2002 to keep the category axis names in all circumstan...

MS chart control for VC++9 03-13-10
I am trying to use MSchart control in my Visual C++9, However, the MS chart control in not available in activex list!. I ve downloaded the MS chart control for APS. Net but I couldnt use it with my VC++ programs. Is there any clue? thanks On Fri, 12 Mar 2010 17:50:52 -0800, Azed <user@msgroups.net/> wrote: >I am trying to use MSchart control in my Visual C++9, However, the MS chart control in not available in activex list!. I ve downloaded the MS chart control for APS. Net but I couldnt use it with my VC++ programs. >Is there any clue? >thanks > >--- >frmsrcur...

D-Link disabled my welcome screen and fast user switching option
I installed a D-Link Xtreme N desktop PCI adaptor with their software. It disabled my welcome screen and fast user switching. XP is telling me I need to uninstall the D-Link software to be able to change this setting. Help? -- dewbru ------------------------------------------------------------------------ dewbru's Profile: http://forums.techarena.in/members/225479.htm View this thread: http://forums.techarena.in/xp-hardware/1341387.htm http://forums.techarena.in ...

Chart of Accounts Details
Can you use alphanumerics or just numerics when defining a chart of account id? You can use an Alphanumeric chart but proceed carefully - it often proved to be impractical and rigid. HS "Royden Akerley" <royden.akerley@brascanpower.com> wrote in message news:225d201c45d4c$6f57a8d0$a301280a@phx.gbl... > Can you use alphanumerics or just numerics when defining a > chart of account id? Some auditors have problems with alpha account numbers. Proceed with caution. "Royden Akerley" <royden.akerley@brascanpower.com> wrote in message news:225d201c45d4c$6f5...

Removing a Link
How do I remove a link to another worksheet? I have a workbook which has several sheets containing links to each other within the workbook only. The mistake I made is that I copied one of the sheets to a new file in order to email just that sheet to somebody. My problem now is that my original workbook will not function properly as it thinks it is linked to the new file that I no longer need and have since deleted. There does not seem to be a straightforward way to delete a link to another workbook. How do I get back to where I was originally? Any help would be greatly appreciated. Re...

Replacement for Link Monitor
Does anyone know of a Windows 2000 or 3rd party replacement for 5.5's Link Monitor? Why did MS remove it? Thanks On Mon, 8 Nov 2004 15:47:02 -0800, "ZLorca" <zlorca2004@yahoo.com> wrote: >Does anyone know of a Windows 2000 or 3rd party replacement for 5.5's Link >Monitor? Why did MS remove it? > >Thanks > On the properties of the server there is the Monitoring tab. That's one part of it. at the bottom of ESM there is the Tools > Monitoring & Status > Notifications object. That's the other half of it. It all works pretty much the sa...

How to link database using vc?
Hello all: I want to program a code about database using vc,I want to put the database in the server and the application is put in the local PC.I want to know how to link the database,and how to link automatically with code? thanks Your question seems very general and far-reaching! I would suggest you start with using the MFC class CRecordset, which uses ODBC to connect using a Data Source Name (DSN) that is defined for your database. "Lee Tow" <fbjlt@pub3.fz.fj.cn> wrote in message news:OQt4jlGoFHA.1204@tk2msftngp13.phx.gbl... > Hello all: > I want to program a co...