I have this code:
The first line that tries .Chart.SetSourceData always fails, so I have to comment it out, and allow the second line instead.Code:With ActiveWorkbook.ActiveSheet .Cells(1, 1) = "Time" .Cells(1, 2) = "Temperature" .Cells(1, 3) = "Target" .Name = Format(Now, "dd-MMM-yyyy") .ListObjects.Add(xlSrcRange, Range("A1:C2"), , xlYes).Name = "Table1" Set cht = ActiveSheet.ChartObjects.Add(Left:=ActiveSheet.Cells(2, 5).Left, Width:=750, Top:=ActiveSheet.Cells(2, 5).Top, Height:=250) With cht .Chart.ChartType = xlXYScatterLines .Chart.SetSourceData ActiveSheet.Range("Table1[#All]") .Chart.SetSourceData ActiveSheet.Range("A1:C2") .Chart.HasTitle = True
I see:
Run-time error "1004"
"Application-defined or object-defined error."
I am trying to ensure the chart automatically updates when new data is added to the Table1 cells, but unsuccessfully!
Any help would be much appreciated.




Reply With Quote
