Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Windows cannot find ___.xls. Make sure you typed the name correc annnicho Excel Discussion (Misc queries) 9 September 14th 07 03:26 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
How X-ax reflect correc time interval when don't have all points Narges Charts and Charting in Excel 1 April 12th 06 04:00 PM


All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"