PC Review


Reply
Thread Tools Rate Thread

Delete a chart

 
 
=?Utf-8?B?U2hlbGw=?=
Guest
Posts: n/a
 
      23rd Oct 2007
I have created a chart in code as follows:

Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Analysis").Range("B1:C3"),
PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Analysis"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With

How do I delete the chart in code?

Thanks

--
Shell
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      23rd Oct 2007
Have you tried recording a macro?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Shell" <(E-Mail Removed)> wrote in message
news:BCC71AF2-BBCF-4D3B-85AA-(E-Mail Removed)...
>I have created a chart in code as follows:
>
> Charts.Add
> ActiveChart.ChartType = xlLineMarkers
> ActiveChart.SetSourceData Source:=Sheets("Analysis").Range("B1:C3"),
> PlotBy:= _
> xlColumns
> ActiveChart.Location Where:=xlLocationAsObject, Name:="Analysis"
> With ActiveChart
> .HasTitle = False
> .Axes(xlCategory, xlPrimary).HasTitle = False
> .Axes(xlValue, xlPrimary).HasTitle = False
> End With
>
> How do I delete the chart in code?
>
> Thanks
>
> --
> Shell


 
Reply With Quote
 
Nigel
Guest
Posts: n/a
 
      23rd Oct 2007

Charts.Add
myChart = ActiveChart.Name



Sheets(myChart).Delete


--

Regards,
Nigel
(E-Mail Removed)



"Shell" <(E-Mail Removed)> wrote in message
news:BCC71AF2-BBCF-4D3B-85AA-(E-Mail Removed)...
>I have created a chart in code as follows:
>
> Charts.Add
> ActiveChart.ChartType = xlLineMarkers
> ActiveChart.SetSourceData Source:=Sheets("Analysis").Range("B1:C3"),
> PlotBy:= _
> xlColumns
> ActiveChart.Location Where:=xlLocationAsObject, Name:="Analysis"
> With ActiveChart
> .HasTitle = False
> .Axes(xlCategory, xlPrimary).HasTitle = False
> .Axes(xlValue, xlPrimary).HasTitle = False
> End With
>
> How do I delete the chart in code?
>
> Thanks
>
> --
> Shell


 
Reply With Quote
 
=?Utf-8?B?U2hlbGw=?=
Guest
Posts: n/a
 
      23rd Oct 2007
Yes I have. it crashes. I need to rerun it to get the err msg.
Note: the chart is embedded on the same sheet as the data.
--
Shell


"Don Guillett" wrote:

> Have you tried recording a macro?
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Shell" <(E-Mail Removed)> wrote in message
> news:BCC71AF2-BBCF-4D3B-85AA-(E-Mail Removed)...
> >I have created a chart in code as follows:
> >
> > Charts.Add
> > ActiveChart.ChartType = xlLineMarkers
> > ActiveChart.SetSourceData Source:=Sheets("Analysis").Range("B1:C3"),
> > PlotBy:= _
> > xlColumns
> > ActiveChart.Location Where:=xlLocationAsObject, Name:="Analysis"
> > With ActiveChart
> > .HasTitle = False
> > .Axes(xlCategory, xlPrimary).HasTitle = False
> > .Axes(xlValue, xlPrimary).HasTitle = False
> > End With
> >
> > How do I delete the chart in code?
> >
> > Thanks
> >
> > --
> > Shell

>
>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      23rd Oct 2007
You need to delete the chart object. So try something like

ActiveChart.Parent.Delete

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Shell" <(E-Mail Removed)> wrote in message
news:17F34AFF-6D83-4BE4-BE15-(E-Mail Removed)...
> Yes I have. it crashes. I need to rerun it to get the err msg.
> Note: the chart is embedded on the same sheet as the data.
> --
> Shell
>
>
> "Don Guillett" wrote:
>
>> Have you tried recording a macro?
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "Shell" <(E-Mail Removed)> wrote in message
>> news:BCC71AF2-BBCF-4D3B-85AA-(E-Mail Removed)...
>> >I have created a chart in code as follows:
>> >
>> > Charts.Add
>> > ActiveChart.ChartType = xlLineMarkers
>> > ActiveChart.SetSourceData Source:=Sheets("Analysis").Range("B1:C3"),
>> > PlotBy:= _
>> > xlColumns
>> > ActiveChart.Location Where:=xlLocationAsObject, Name:="Analysis"
>> > With ActiveChart
>> > .HasTitle = False
>> > .Axes(xlCategory, xlPrimary).HasTitle = False
>> > .Axes(xlValue, xlPrimary).HasTitle = False
>> > End With
>> >
>> > How do I delete the chart in code?
>> >
>> > Thanks
>> >
>> > --
>> > Shell

>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete chart NonTechie Microsoft Excel Charting 7 24th Sep 2009 05:59 AM
Delete Chart sq75222 Microsoft Access Queries 7 18th Mar 2008 01:47 AM
delete chart =?Utf-8?B?V2F5bmU=?= Microsoft Excel Misc 6 3rd May 2007 03:00 PM
Delete Chart =?Utf-8?B?YWdhYzgxMDM=?= Microsoft Excel Charting 3 13th Dec 2004 04:54 AM
Using VBA to Delete a Chart MikeM Microsoft Excel Programming 3 14th Oct 2003 02:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:01 PM.