Hi all,
I am using Excel 2016 and want to update a "Box and Whisker" chart with new "Source Data" in a dynamic range.
One workaround is to delete "Chart 1" and create a new "Box and Whisker" chart but how to update existing chart?
I have tried below code and others but I can't get it to work.
Any help is much appreciated.
I am using Excel 2016 and want to update a "Box and Whisker" chart with new "Source Data" in a dynamic range.
One workaround is to delete "Chart 1" and create a new "Box and Whisker" chart but how to update existing chart?
I have tried below code and others but I can't get it to work.
Code:
Sub ChartData1()
Dim ChartRange1 As Range
Dim LR As Long
LR = Columns("A:G").Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
With ActiveSheet.ChartObjects("Chart 1").Chart.ChartArea
'On Error Resume Next 'With "On Error": "Chart 1" is updated with new "Source" range!
ActiveChart.SetSourceData Source:=Range(Cells(4, 1), Cells(LR, 7)) 'Without "On Error": runtime error 445, object doesn't support this action
'On Error GoTo 0
End With
End Sub
Any help is much appreciated.