range select not working with small sets
I am using coding to automate some charts. It works great unless my data set
has fewer than 25 lines. When the data set is small (<25 rows) the code
interrupts. Debugging takes me to:
ActiveCell.FormulaR1C1 = "=average(RC2:r[-" & mysmooth - 1 & "]c2)"
the section of coding that this applies to is:
'determine smoothing
Range("f20").Select
ActiveCell.Formula = "=LOOKUP(" & numberrows & ",'[Trending Source
rework 2.xls]Stats'!R1C1:R5C1,'[Trending Source rework
2.xls]Stats'!R1C2:R5C2)"
mysmooth = ActiveCell.Value
Range("F21").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""PI Smoothing ("",smooth,""
Point)"")"
Range("h" & mysmooth + 2).Select
ActiveCell.FormulaR1C1 = "=average(RC2:r[-" & mysmooth - 1 & "]c2)"
Selection.AutoFill Destination:=Range("h" & mysmooth + 2 & ":h" &
numberrows), Type:=xlFillDefault
Columns("h").EntireColumn.AutoFit
The table on the STATs sheet is in A1:b5
0 0
25 4
50 6
150 12
250 18
Anything over 25 rows it works fine.
Any ideas?
TIA
|