Why can't I copy and paste vertical chart lines added in VBA

Ummm1

New Member
Joined
May 1, 2014
Messages
12
Hi, I have this VBA code to generate multiple line charts on a few pages. Overlaid on the data lines on each chart are two vertical lines that mark two x-axis dates consistent among all the charts. The charts look fine when they're produced but when I copy and paste them (no matter the format) the two vertical lines go away. Perhaps the x-axis min and max need to be explicitly stated for the vertical lines? This was the case for the data lines themselves. But I don't see how to do this for the vertical lines. Can anyone help?

Thanks!

_________________

chartplace = 25
For chartcount = 1998 To 2013 Step 1
If chartcount = 2012 Then chartcount = chartcount + 1
Sheets("wtchart").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("wt " & CStr(chartcount) & " array").Range("B5:B118,D5:D118")

' The first series to add is number 2; each subsequent series adds 1

seriescount = 2

' The first series to add is in column 6; subsequent series are in every other column
' The last column in the array sheet is column "GO", which is column number 197.

For colcount = 6 To 197 Step 2

ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriescount).Name = "='wt " & CStr(chartcount) & " array'!r5c" & colcount
ActiveChart.SeriesCollection(seriescount).Values = "='wt " & CStr(chartcount) & " array'!r6c" & colcount & ":r118c" & colcount

seriescount = seriescount + 1
Next colcount

'adds vertical lines:

ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriescount).ChartType = xlXYScatterLinesNoMarkers
Sheets("wg_cht_dummy_data").Range("A5:D5") = Array("=NA()", 0, 130, "=NA()")
Sheets("wg_cht_dummy_data").Range("A6:D6") = Array("10jun" & chartcount, "18aug" & chartcount, "18aug" & chartcount, "15sep" & chartcount)
ActiveChart.SeriesCollection(seriescount).Values = Sheets("wg_cht_dummy_data").Range("A5:D5")
ActiveChart.SeriesCollection(seriescount).XValues = Sheets("wg_cht_dummy_data").Range("A6:D6")
ActiveChart.SeriesCollection(seriescount).AxisGroup = 1

seriescount = seriescount + 1

ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriescount).ChartType = xlXYScatterLinesNoMarkers
Sheets("wg_cht_dummy_data").Range("A7:D7") = Array("=NA()", 0, 130, "=NA()")
Sheets("wg_cht_dummy_data").Range("A8:D8") = Array("10jun" & chartcount, "28aug" & chartcount, "28aug" & chartcount, "15sep" & chartcount)
ActiveChart.SeriesCollection(seriescount).Values = Sheets("wg_cht_dummy_data").Range("A7:D7")
ActiveChart.SeriesCollection(seriescount).XValues = Sheets("wg_cht_dummy_data").Range("A8:D8")
ActiveChart.SeriesCollection(seriescount).AxisGroup = 1

'end add vertical lines

With ActiveChart.Parent
.Top = chartplace
.Left = 275
End With

With ActiveChart
.HasTitle = True
.ChartTitle.Font.Size = 6
.ChartTitle.Text = chartcount
.HasLegend = False
.Axes(xlCategory).MajorUnit = 3
.Axes(xlCategory).TickLabelPosition = xlNone
.Axes(xlCategory).TickLabels.Font.Size = 5
.Axes(xlCategory).TickLabels.Font.Name = "Arial"
.Axes(xlCategory).TickLabels.NumberFormat = "[$-409]d-mmm-yy;@"
.Axes(xlCategory).TickLabels.Orientation = xlUpward
.Axes(xlValue).TickLabels.Font.Size = 6
.Axes(xlValue).MinimumScale = 0
.Axes(xlValue).MaximumScale = 130
.Axes(xlCategory).MinimumScale = "10Jun" & chartcount
.Axes(xlCategory).MaximumScale = "15Sep" & chartcount
.Axes(xlValue).MajorUnit = 10
.ChartArea.Width = 225
.ChartArea.Height = 125
.PlotArea.Top = 20
.PlotArea.Height = 110
.PlotArea.Width = 220
End With

chartplace = chartplace + 125
Next chartcount
With ActiveChart
.Axes(xlCategory).TickLabelPosition = xlNextToAxis
End With
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Oops, I forgot that I HAD added min and max scale to the vertical lines section. So that's not the problem.
 
Upvote 0
Another hint, possibly, is that the last chart at the bottom--the one with the x-axis tick labels (the other charts has those labels omitted) does what I want them all to do: copy and paste with the vertical lines included. So somehow, including the tick labels makes the lines stick in a copy-and-paste.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top