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".
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.
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,
Julian
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.
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.