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
855
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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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