Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Test for presence of chart on active sheet

I've written the following code to create a chart on the active sheet.


'Select the range of data to chart (using the value from FindLastUsedRow)
Range(Cells(2, 1), Cells(intLastRow, 7)).Select

'Create the chart
With ActiveSheet.ChartObjects.Add(Left:=100, Width:=375, Top:=75,
Height:=255).Chart
.SetSourceData Source:=ActiveSheet.Range(Cells(2, 1), Cells(intLastRow,
7))
.ChartType = xlColumnClustered
.Axes(xlValue).MajorUnit = 1
End With


Two questions....

1) How can I check for the presence of a chart on the active sheet? The idea
is that the user clicks the button to initially create and then update the
chart, and I figured deleting and redrawing it would be the way to do this. I
need to be able to check if the chart on that sheet has already been created
and, if so, delete it.

2) Can someone explain to me the units of measurement that decide
whereabouts in the sheet the chart is placed? I got the (Left:=100,
Width:=375, Top:=75, Height:=255) above from the macro recorder, which is all
well and good but I don't understand exactly how it works.

Any suggestions greatly appreciated :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Test for presence of chart on active sheet

1. if activesheet.chartobjects.count is zero, there are no charts.
2. the measurements are points: refer to the help file & search for 'Left
Property'

"Katherine" wrote:

I've written the following code to create a chart on the active sheet.


'Select the range of data to chart (using the value from FindLastUsedRow)
Range(Cells(2, 1), Cells(intLastRow, 7)).Select

'Create the chart
With ActiveSheet.ChartObjects.Add(Left:=100, Width:=375, Top:=75,
Height:=255).Chart
.SetSourceData Source:=ActiveSheet.Range(Cells(2, 1), Cells(intLastRow,
7))
.ChartType = xlColumnClustered
.Axes(xlValue).MajorUnit = 1
End With


Two questions....

1) How can I check for the presence of a chart on the active sheet? The idea
is that the user clicks the button to initially create and then update the
chart, and I figured deleting and redrawing it would be the way to do this. I
need to be able to check if the chart on that sheet has already been created
and, if so, delete it.

2) Can someone explain to me the units of measurement that decide
whereabouts in the sheet the chart is placed? I got the (Left:=100,
Width:=375, Top:=75, Height:=255) above from the macro recorder, which is all
well and good but I don't understand exactly how it works.

Any suggestions greatly appreciated :)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Test for presence of chart on active sheet



"AA2e72E" wrote:

1. if activesheet.chartobjects.count is zero, there are no charts.
2. the measurements are points: refer to the help file & search for 'Left
Property'


Thanks, the activesheet.chartobjects.count is just what I needed.

As for 2) I'd already tried searching the help files (both excel help and
the vbe help) but hadn't come across any useful results. Nevermind, I'll keep
googling it.
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
How can I test a range of cells for the presence of a border? PFB Excel Worksheet Functions 7 November 10th 08 05:19 AM
Copy sheet and make new sheet active belvy123 Excel Discussion (Misc queries) 5 April 24th 08 03:33 PM
Active Cell Copy And Paste Sheet to Sheet A.R.J Allan Jefferys New Users to Excel 4 May 4th 06 02:04 AM
Need to test for file presence Grant Excel Programming 3 October 26th 04 08:57 PM
Test if Active Cell is in a named range Simon Shaw[_5_] Excel Programming 1 September 28th 04 12:11 AM


All times are GMT +1. The time now is 10:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"