captculver
Board Regular
- Joined
- Dec 8, 2008
- Messages
- 60
I have VBA code written to copy a graph, delete 2 series from the graph, replace the values of another series, and then add 2 new series. I do not want to graph the 2 new series in the plot area; I just want the values displayed in the data table. I'm working with patient satisfaction scores and I have the goal and score graphed in the plot area; the 2 new series I'm adding are the numerator and denominator. Typically these won't show up in the plot area since the MIN and MAX values for the axis are set at .5 and 1.0 (50% to 100%). However, we do have a couple of low volume units where we could see a numerator or denominator of 1 or 0 and I don't want those series lines to show in the graph.
The macro recorder clued me in on how to eliminate the markers, but not the line. Here's the code I have so far:
Private Sub Copy_SLHS_CHARTS()
' OVERALL CHART QUESTIONS
'
Worksheets("SLHS_DB").ChartObjects("OVERALL_SLHS_CHT").Activate
ActiveChart.ChartArea.Copy
Range("F75").Select
ActiveSheet.Paste
With ActiveChart
.Parent.Name = "Q21_SLHS_CHT"
.ChartTitle.Text = "SLHS Q21"
.SeriesCollection(2).Delete
.SeriesCollection(2).Delete
End With
ActiveSheet.ChartObjects("Q21_SLHS_CHT").Activate
With ActiveChart.SeriesCollection(2)
.Name = "Q21"
.Values = "Q21!Q21_SLHS_P_12"
.XValues = "Q21!Q21_CHTCAT_12"
End With
With ActiveChart.SeriesCollection.NewSeries
.Name = "Num"
.Values = "Q21!Q21_slhs_n_12"
.XValues = "q21!Q21_chtcat_12"
.MarkerStyle = xlMarkerStyleNone
End With
With ActiveChart.SeriesCollection.NewSeries
.Name = "Den"
.Values = "Q21!Q21_SLHS_D_12"
.XValues = "Q21!Q21_CHTCAT_12"
.MarkerStyle = xlMarkerStyleNone
End With
End Sub
Thanks very much for your time and assistance.
Chuck
The macro recorder clued me in on how to eliminate the markers, but not the line. Here's the code I have so far:
Private Sub Copy_SLHS_CHARTS()
' OVERALL CHART QUESTIONS
'
Worksheets("SLHS_DB").ChartObjects("OVERALL_SLHS_CHT").Activate
ActiveChart.ChartArea.Copy
Range("F75").Select
ActiveSheet.Paste
With ActiveChart
.Parent.Name = "Q21_SLHS_CHT"
.ChartTitle.Text = "SLHS Q21"
.SeriesCollection(2).Delete
.SeriesCollection(2).Delete
End With
ActiveSheet.ChartObjects("Q21_SLHS_CHT").Activate
With ActiveChart.SeriesCollection(2)
.Name = "Q21"
.Values = "Q21!Q21_SLHS_P_12"
.XValues = "Q21!Q21_CHTCAT_12"
End With
With ActiveChart.SeriesCollection.NewSeries
.Name = "Num"
.Values = "Q21!Q21_slhs_n_12"
.XValues = "q21!Q21_chtcat_12"
.MarkerStyle = xlMarkerStyleNone
End With
With ActiveChart.SeriesCollection.NewSeries
.Name = "Den"
.Values = "Q21!Q21_SLHS_D_12"
.XValues = "Q21!Q21_CHTCAT_12"
.MarkerStyle = xlMarkerStyleNone
End With
End Sub
Thanks very much for your time and assistance.
Chuck