G
George Raft
I'm working in Excel 97 on either Win 98 or XP. I want to create either an
embedded chart or a chart sheet depending on whether a checkbox
(chkNewSheet) on a user form (frmBoxPlot - yes, this is trying to automate
boxplots) is checked.
Here is the code I'm using:
If frmBoxPlot.chkNewSheet Then
Set chBoxPlot = Charts.Add
chBoxPlot.Location Where:=xlLocationAsNewSheet, Name:="BoxPlot"
chBoxPlot.SetSourceData Source:=rngOut, PlotBy:=xlRows
chBoxPlot.ChartType = xlLineMarkers
Else 'user wants it on the current sheet
Set obBoxPlot = ActiveSheet.ChartObjects.Add(72, 72, 400, 300)
obBoxPlot.Location Where:=xlLocationAsObject, Name:=ActiveSheet.Name
obBoxPlot.SetSourceData Source:=rngOut, PlotBy:=xlRows
obBoxPlot.ChartType = xlLineMarkers
End If
obBoxPlot is type ChartObject, chBoxPlot is type Chart. rngOut is the data
range containing the series to be plotted.
Okay, here's what happens. If chkNewSheet is true, then Excel creates a new
sheet and populates the chart as expected. If chkNewSheet is false, it
opens an empty chart window on the active sheet.
What am I missing??
embedded chart or a chart sheet depending on whether a checkbox
(chkNewSheet) on a user form (frmBoxPlot - yes, this is trying to automate
boxplots) is checked.
Here is the code I'm using:
If frmBoxPlot.chkNewSheet Then
Set chBoxPlot = Charts.Add
chBoxPlot.Location Where:=xlLocationAsNewSheet, Name:="BoxPlot"
chBoxPlot.SetSourceData Source:=rngOut, PlotBy:=xlRows
chBoxPlot.ChartType = xlLineMarkers
Else 'user wants it on the current sheet
Set obBoxPlot = ActiveSheet.ChartObjects.Add(72, 72, 400, 300)
obBoxPlot.Location Where:=xlLocationAsObject, Name:=ActiveSheet.Name
obBoxPlot.SetSourceData Source:=rngOut, PlotBy:=xlRows
obBoxPlot.ChartType = xlLineMarkers
End If
obBoxPlot is type ChartObject, chBoxPlot is type Chart. rngOut is the data
range containing the series to be plotted.
Okay, here's what happens. If chkNewSheet is true, then Excel creates a new
sheet and populates the chart as expected. If chkNewSheet is false, it
opens an empty chart window on the active sheet.
What am I missing??