I have the following code, but can't seem to correct the error generated with the line that sets the source data. Can someone help me out? I have data in columns A and B, but the # of rows vary based on a combobox pulldown value. I would like the chart to update automatically with the # of rows that get populated with data. Thanks in advance for any help.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRow As Long
Dim MyRange As Range
LastRow = Range("A1").End(xlDown).Row
Set MyRange = Range("A1:B" & LastRow)
If Not Intersect(Target, MyRange) Is Nothing Then
ActiveSheet.ChartObjects("Chart 3").SetSourceData _
Source:=Sheets("Sheet2").Range(MyRange)
End If
End Sub
Bookmarks