I'm trying to set the data set for a chart object using a macro. The macro selects the correct range that I want (I check by using rng.Select and debugging) but when I right click the chart object after the macro has finished running and select Select Data it says the data range is too complex to display and does not correctly populate my chart. My macro is below. Any pointers appreciated.
EDIT. I have a copy of the sheet where the graph was created from the populated data manually and clicking Select Data on this chart shows the non-contiguous range just fine - it's only when trying to set it by macro for a pre-existing chart that it doesn't work.
Sub test()
UpdateChart 27, 64
End Sub
Sub UpdateChart(ByVal row As Long, ByVal col As Long)
Dim sht As Worksheet
Set sht = Worksheets("Report4_Chart")
Dim data As Worksheet
Set data = Worksheets("Report4")
Dim rng As Range
Dim exclude As Range
data.Activate
Set exclude = data.Rows(25)
Set rng = data.Range("A24", Intersect(data.Rows(row), data.Columns(col)))
Set rng = SetDifference(rng, exclude)
rng.Select
sht.Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:=rng
End Sub
