Loading (Showing) Chart error

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
When I get to line "co Activate" - I get RT Error '-214702... - (80070057)
Requested Shapes are locked for selection. How do I Correct this?

Code:
Sub BringUpChart()
Dim co As ChartObject
Dim ch As Chart
Set co = ActiveSheet.ChartObjects("MyChart")
'Set ch = co.Chart
    CRow = ActiveCell.Row
    Set CRange = Application.Union(Range("B" & CRow), Range("C" & CRow), Range("M" & CRow))
    co.Activate
    co.SetSourceData Source:=CRange, PlotBy:=xlRows
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Jim,

I'm guessing the chart is locked and the sheet is protected, which disallows activating the chart. If this is the case, you have two options:

1. Unlock the chart. This will mean the chart can be edited even though the sheet is protected. To unlock the chart, first unprotect the sheet, then select the chart using Ctrl-left click. Now that it is selected you can right-click on it, then select Format Object, then the Protection tab. Uncheck the Locked checkbox. Then you can re-protect the sheet.

2. Have your code modify the chart without selecting or activating it. I believe you can simply eliminate the co.Activate line. If it still won't allow your code to modify the chart, then add code to unprotect and reprotect the chart:

Code:
Activesheet.UnProtect "mypassword"
    co.SetSourceData Source:=CRange, PlotBy:=xlRows
Activesheet.Protect "mypassword"

You can then protect your VBAProject (your code) so that nobody can look at it to see your password by protecting it. To do this, in the VBE select Tools > VBAProject Properties > Protection tab and assign a password to the project.

Damon
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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