Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to delete charts
Is it possible to create a macro that can select and delete all of the
charts in a workbook. Regardless of their names? --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to delete charts
This will remove chart sheets and embedded charts:
'==================================== Sub ChartsDelete() Dim ch As Chart Dim ws As Worksheet Dim chObj As ChartObject Application.DisplayAlerts = False For Each ch In ActiveWorkbook.Charts ch.Delete Next For Each ws In ActiveWorkbook.Worksheets For Each chObj In ws.ChartObjects chObj.Delete Next Next Application.DisplayAlerts = True End Sub '================================== bambam77 wrote: Is it possible to create a macro that can select and delete all of the charts in a workbook. Regardless of their names? -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to delete charts
Thank you, this worked great. I have another question. I am new to thi
macro writing and I have done a few projects so far that have worked. I have never used the Dim command, yet I see this a lot from peopl here and in the delete chart code I just received. What is this Dim And what does it do and when do I need it? I know it has something to do with defining variables. I have used som variables in some of my macros without the Dim command and they worke fine so I'm kind of confused as to it's use. Thank -- Message posted from http://www.ExcelForum.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to delete charts
Good Practice is to start your code with
OPTION EXPLICIT then you will need to define variables with the DIM statement, but avoid problems with duplicate names etc "bambam77 " wrote in message ... Thank you, this worked great. I have another question. I am new to this macro writing and I have done a few projects so far that have worked. I have never used the Dim command, yet I see this a lot from people here and in the delete chart code I just received. What is this Dim? And what does it do and when do I need it? I know it has something to do with defining variables. I have used some variables in some of my macros without the Dim command and they worked fine so I'm kind of confused as to it's use. Thanks --- Message posted from http://www.ExcelForum.com/ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to delete charts
And if you use "option explicit" and dim your variables appropriately, then you
can get the VBE's intellisense to pop up for you. (Less wear and tear on the memory!) Try this in a test module: Option explicit sub testme() Dim Wks as worksheet 'now type wks. (as soon as you hit that dot, you should see some valid choices for what you can do to a worksheet (or a property of the worksheet that you can examine). This is very nice to us older folks. And by forcing you to declare your variables, you don't have to spend hours looking for the mistake in this code: for xlctr = 1 to 5 msgbox x1ctr next xlctr (the one's and ell's are mixed up). You would have gotten an error when you tried to compile. And this is nice to us older folks with bifocals! "bambam77 <" wrote: Thank you, this worked great. I have another question. I am new to this macro writing and I have done a few projects so far that have worked. I have never used the Dim command, yet I see this a lot from people here and in the delete chart code I just received. What is this Dim? And what does it do and when do I need it? I know it has something to do with defining variables. I have used some variables in some of my macros without the Dim command and they worked fine so I'm kind of confused as to it's use. Thanks --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete a sheet and access charts | Excel Worksheet Functions | |||
Delete ALL Charts in a WorkSheet (VB) | Charts and Charting in Excel | |||
How can I delete a macro when the Delete button is not active? | Excel Worksheet Functions | |||
How do i delete a macro in Excel 2003 when delete isn't highlight | Excel Discussion (Misc queries) |