Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I test a range of cells for the presence of a border? | Excel Worksheet Functions | |||
Copy sheet and make new sheet active | Excel Discussion (Misc queries) | |||
Active Cell Copy And Paste Sheet to Sheet | New Users to Excel | |||
Need to test for file presence | Excel Programming | |||
Test if Active Cell is in a named range | Excel Programming |