LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Simple Macro Modification

Hi All!

I know this should be a simple change, however it is currently eluding
me for some reason.

The code below finds groupings of values over 150 and stops after the
values that go below 150. It then lists all of the averaged groupings.


What I now need to do is when the value is over 150, it will average
the next 12 cells below in the column and then keep doing that for the
entire range. So basically, instead of averaging the various groupings
over 150, it needs to average the groupings of 12 cells that begin with
a value over 150. I hope that I explained that thoroughly enough!

The following is the code that I currently have:

Option Explicit
Sub AvgGT15()
Dim AOI As Range
Dim StoreResult As Range
Dim c As Range
Dim i As Long
Dim Result()

Set StoreResult = [M1]
Set AOI = [D1:D52111]
[M1:M52111].ClearContents

i = 0
ReDim Preserve Result(i)

For Each c In AOI
If c.Value < 150 Then
If Result(0) = 150 Then
StoreResult.Value =
Application.WorksheetFunction.Average(Result())
Set StoreResult = StoreResult.Offset(1, 0)
End If
i = 0
Result(0) = 0
Else
ReDim Preserve Result(i)
Result(i) = c.Value
i = i + 1
End If
Next c

If Result(0) = 150 Then StoreResult.Value = _
Application.WorksheetFunction.Average(Result())

End Sub


That's it!!! Please post suggestions and modifications!

Thanks in advance,

Kris Taylor
www.QuestOfAges.org Administrator

 
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
Macro Modification Help akemeny Excel Discussion (Misc queries) 1 December 3rd 08 06:11 PM
Macro Modification carl Excel Worksheet Functions 0 May 4th 07 04:17 PM
Macro Modification Help Dmorri254 Excel Worksheet Functions 0 March 4th 05 03:51 PM
Macro Modification Help MM[_4_] Excel Programming 1 July 29th 04 10:37 PM
Need Macro Modification Phil Hageman[_3_] Excel Programming 2 June 2nd 04 12:26 PM


All times are GMT +1. The time now is 12:28 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"