HELP to correc this macro
I got an error: (Run-time error '1004': Application-defined or object-defined
error). Thanks, Sub Avg3Row() Dim OutputRow As Integer OutputRow = 1 For Row = Selection.Row To ActiveSheet.UsedRange.Rows.Count Step 30 Worksheets("Output").Cells(OutputRow, 1).Formula = "=average(Input!B" & Row - 3 & ":B" & Row & ")" OutputRow = OutputRow + 1 Next Row End Sub |
HELP to correc this macro
It's better not to use Row as the count variable, given that this a reserved
word - make it myRow or some-such, and DIM it at the beginning of the macro. Also, if you have selected cells on rows 1 to 3, then you will be trying to set up an average for cells B-2, B-1 or B0 - such cells don't exist !! Hope this helps. Pete "bioyyy" wrote in message ... I got an error: (Run-time error '1004': Application-defined or object-defined error). Thanks, Sub Avg3Row() Dim OutputRow As Integer OutputRow = 1 For Row = Selection.Row To ActiveSheet.UsedRange.Rows.Count Step 30 Worksheets("Output").Cells(OutputRow, 1).Formula = "=average(Input!B" & Row - 3 & ":B" & Row & ")" OutputRow = OutputRow + 1 Next Row End Sub |
All times are GMT +1. The time now is 10:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com