When copying a chart generated by my macro and pasting as a picture (to avoid chart rendering while scrolling as a lot of data points are involved), the pasted picture of the chart does not display the same data.
I am a novice excel vba user, so I'm probably doing something incorrect here...
In just excel, I have tried right-clicking my chart and pasting as a picture and receive the same issue. I think there might be a limitation with the amount of data I'm working with (~11k data points), but since I'm not receiving an error I'm not sure.
I have tried different methods of copying the chart in excel vba (chartarea.copy, chart.copypicture) with no success.
Here is part of the code of interest....
'This is a small snippet of a much larger range of code, certain ranges/variables are defined earlier
Set localDate = Sheets(1).Range("A2:A" & lastRow)
Set plasmaNaVisRange = plasmaNaRange.SpecialCells(xlCellTypeVisible)
Set plasmaNaChart = Sheets(4).Shapes.AddChart.Chart
'Clears automatic charting done on source sheet
plasmaNaChart.ChartArea.ClearContents
With plasmaNaChart
.ChartType = xlXYScatter
.SetSourceData Source:=Range(localDate, plasmaNaVisRange), PlotBy:=xlColumns
.SetElement (msoElementChartTitleAboveChart)
.ChartTitle.Text = "Plasma"
.Parent.Height = 276
.Parent.Width = 466
.Axes(xlCategory).TickLabels.Orientation = 45
End With
'Forces correct assignment of axes
With plasmaNaChart.SeriesCollection(1)
.XValues = localDate
.Values = plasmaNaVisRange
.Name = "Na"
End With
'Everything appears correct up to this point and chart displays as corrected
plasmaNaChart.ChartArea.Copy
Sheets(4).Range("B36").Select
Sheets(4).Pictures.Paste
plasmaNaChart.Parent.Delete
On the original chart I see all my data points with correct axes (y-axis ranges around 0-160, x-axis lists the dates correctly). On the pasted chart I have no Y-values and confirmed as much when I pasted it keeping source and found nothing in the y-series. Also my x-axis is completely messed up and has dates ranging from 1/0/1900 to 11/21/2036
plasmaNaChart.CopyPicture
– Tim WilliamsCopy
, does the chart look OK? – Tim Williams