Forum

Dynamic chart sourc...
 
Notifications
Clear all

Dynamic chart source data update

5 Posts
2 Users
0 Reactions
107 Views
(@julian)
Posts: 82
Estimable Member
Topic starter
 

I tried to write a procedure to update a chart source data specifying the correspondent worksheet as follows:

Sub ChartSource()
'
Dim ws As String
ws = ActiveSheet.Range("B16").Value
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:=Sheets(ws).Range("A165:B365")

End Sub

Thanks in advance to guide me to fix the error "subscript out of range".

 
Posted : 15/12/2021 11:31 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Julian,

The worksheet name seems to come from range B16 of the ACTIVE SHEET.

Make sure the correct sheet is ACTIVE before running the code and what you have in B16 is the name of an existing sheet.

 
Posted : 16/12/2021 3:37 am
(@julian)
Posts: 82
Estimable Member
Topic starter
 

Hi Catalin,

My value of B16 comes from a data validation referring to a previous list I didn't update. Thanks for your highlight. Take the chance could you please help me on another little problem:

I've changed the font size of the code on VBE through Tools > Options > Editor Format but failed to save it even after pressing the "OK" button. Why?

Sorry for bothering you so much!

Best regards,

JulianEmbarassed

 
Posted : 16/12/2021 7:28 pm
(@catalinb)
Posts: 1937
Member Admin
 

On Tools>Options>Editor Format, you have to select from the left side list the TYPE of text you want to change: Normal Text, Selection Text, Comment Text, Breakpoint Text and so on. Each can be formatted as you want.

 
Posted : 17/12/2021 12:27 am
(@julian)
Posts: 82
Estimable Member
Topic starter
 

It seems a little tricky. The left side list is for code colors selection only not valid on font size. Although there are so many font types with limited size can be choosed from the right side drop down list but no English or U.S.A version found. That's my finding. Finally I choose Verdana (West Europe) to enhance my visibility. 

 
Posted : 17/12/2021 2:11 am
Share: