Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a Graph as an Object : Urgent!

Hi all,

Could anyone please let me know how I can delete a specific graph on
specific sheet in VBA . I have tried inserting it as an object but thi
doesn't work as I believe it already is an object. I have trie
referring to its TopLeftCell address, I don't think this works and
have also tried the old Workbook.Charts.Delete

Can anyone please help

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a Graph as an Object : Urgent!

Sheets(1).ChartObjects("Chart 2").Delete

will delete a chart- no need to create as an object

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a Graph as an Object : Urgent!

This is correct code however it is not adequate. What happens in my ap
is that when the user wishes to see the graph they click on a button
Thus as the graph is being created it gets a name like ("Chart 207"
thus I what I need to do in my app is firstly check if the graph i
there...

if it is then it should be deleted AND additionally I need to know ho
to reference the graph. eg. Because excel comes up with random grap
names I can just hardcode a....

Sheets("Main").ChartObjects("Chart 276").Delete

Because Chart 276 won't always be chart 276.

Thanks for your help initially, do you have any other ideas??

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a Graph as an Object : Urgent!

If you are using only one chart on a page you could use

Worksheets("Main").ChartObjects(1).Delete

This let me clear a chart from my worksheet.

Dont know if this is the proper way to do this but it worked for me.


Davi

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a Graph as an Object : Urgent!

How about when creating the chart assign to object var

sub CreateChart
dim chMyChart

set chMyChart = Charts.Add
....
....


You can then refer to the chart as a variable.

Other options include looping through all the chart objects in a sheet-
something like

Dim chMyChart

For Each chMyChart In ActiveSheet.ChartObjects
.....
Next
....

Duncan


---
Message posted from http://www.ExcelForum.com/



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
Need Urgent Help Creating a Formula Raich Excel Discussion (Misc queries) 1 February 15th 08 06:50 PM
Creating a graph similar to a stacked column graph Jonathan Charts and Charting in Excel 6 August 4th 06 04:23 PM
VB script in Excel object in Powerpoint (Urgent) epak Excel Discussion (Misc queries) 1 March 24th 06 05:04 PM
Unable to access GridLines in Microsoft Graph Object [URGENT] usamaalam Charts and Charting in Excel 0 March 7th 05 05:29 AM
Urgent: Object Explicit Error Jonathan Lowe Excel Programming 2 October 20th 03 11:14 PM


All times are GMT +1. The time now is 03:01 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"