Out of Memory error when trying to name a chart. How do I name a chart in vba?

OaklandJim

Well-known Member
Joined
Nov 29, 2018
Messages
833
Office Version
  1. 365
Platform
  1. Windows
Here are relevant portions of code:

VBA Code:
    Dim wsData As Worksheet

    Dim cResults As Chart

    Set wsData = ThisWorkbook.Worksheets("Sheet1") '<= worksheet containing data

    Set cResults = wsData.Shapes.AddChart.Chart
    
    With cResults
'
        .ChartType = xlBarClustered

         .SeriesCollection.Add Source:=rDataSeries

'       This causes an out of memory error.
        .Name = "ECR Counts"

    End With

The .Name part gives me Run-time Error 7: Out of Memory. How do I name a chart in vba?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
try:

VBA Code:
.Parent.Name = "ECR Counts"
 
Upvote 0
Solution
Thanks Kokosec

I'm doing my first char by VBA and it is not so straightforward. I appreciate the assistance!

Might you be able to tell me how to delete an existing version of the chart.

I Tried
wsData.Charts("ECR Counts").Parent.Delete

wsData.Shapes("ECR Counts").Parent.Delete
 
Upvote 0

Forum statistics

Threads
1,215,111
Messages
6,123,152
Members
449,098
Latest member
Doanvanhieu

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