spurs
Active Member
- Joined
- Oct 18, 2006
- Messages
- 479
- Office Version
- 2016
- 2013
- 2010
- 2007
- 2003 or older
- Platform
- Windows
When I run the following code in Excel 2003, I do not get an error. When I run it in excel 2007, i get an error :
Run time error 1004:
A formula in the worksheet contains one or more invalid references
Verify that your forumulas contain a valid path, workbook, range name, and cell reference
on the following line
.Formula = "=SERIES(,Data!R1C1:R" & Nreadings & "C1,Data!R1C4:R" &_ Nreadings & "C4,1)"
in the code below
Sheets("TTT Ecc Rem").Unprotect
With Sheets("TTT Ecc Rem").ChartObjects("Chart 1").Chart
.SetSourceData Source:=Sheets("Data").Range("A1:A" & Nreadings),_ PlotBy:=xlColumns
With .SeriesCollection(1)
.Formula = "=SERIES(,Data!R1C1:R" & Nreadings & "C1,Data!R1C4:R" &_ Nreadings & "C4,1)"
.Name = "Ecc Removed"
.Border.ColorIndex = 11
.Border.Weight = xlThin
.Border.LineStyle = xlContinuous
End With
End With
the usual way is to run the code password protected (ie the vba code is password protected) Of course when this happens you cannot see exactly which line of code failed. So when I unprotect the code then run the macro, it shows me the line indicated above as the failed line. The odd thing is that after the error comes up, I can simply press F8 to run a single line of code, and it runs without error and everything looks fine like in excel 2003.
Some notes: the worksheet "Data" is not protected but it is hidden.
Anyone know what causes this?
Run time error 1004:
A formula in the worksheet contains one or more invalid references
Verify that your forumulas contain a valid path, workbook, range name, and cell reference
on the following line
.Formula = "=SERIES(,Data!R1C1:R" & Nreadings & "C1,Data!R1C4:R" &_ Nreadings & "C4,1)"
in the code below
Sheets("TTT Ecc Rem").Unprotect
With Sheets("TTT Ecc Rem").ChartObjects("Chart 1").Chart
.SetSourceData Source:=Sheets("Data").Range("A1:A" & Nreadings),_ PlotBy:=xlColumns
With .SeriesCollection(1)
.Formula = "=SERIES(,Data!R1C1:R" & Nreadings & "C1,Data!R1C4:R" &_ Nreadings & "C4,1)"
.Name = "Ecc Removed"
.Border.ColorIndex = 11
.Border.Weight = xlThin
.Border.LineStyle = xlContinuous
End With
End With
the usual way is to run the code password protected (ie the vba code is password protected) Of course when this happens you cannot see exactly which line of code failed. So when I unprotect the code then run the macro, it shows me the line indicated above as the failed line. The odd thing is that after the error comes up, I can simply press F8 to run a single line of code, and it runs without error and everything looks fine like in excel 2003.
Some notes: the worksheet "Data" is not protected but it is hidden.
Anyone know what causes this?