ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   range select not working with small sets (https://www.excelbanter.com/excel-programming/317169-range-select-not-working-small-sets.html)

Papa Jonah

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


All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com