Good Morning Dastard, Here is a different take on your code. If your data is
blocked like it is in your example (sorted) you can us this code and get the
same results. Post me back if you have questions, got run get to work.
enjoy, Rick (Fairbanks, AK {Land of the Midnight Sun})
Sub GroupAvg()
Dim LastRow As Long, lRow As Long
Dim ws1 As Worksheet
Dim Top As Long
Dim ZoneStr As String
Set ws1 = Worksheets("sheet1")
With ws1
LastRow = .Range("A3").End(xlDown).Row
lRow = 3 '' <- start row
Do
Top = lRow '' save top of range position
ZoneStr = Left(.Cells(Top, "A"), 2) '' ZoneCode string
Do '' loop thru like zonecode string
lRow = lRow + 1 '' to find last postion of like zone code
Loop While (ZoneStr = Left(.Cells(lRow, "A"), 2)) '' this give bottom
of range (lrow-1)
Range("C" & Top).Formula = "=Average(B" & Top & ":B" & lRow - 1 & ")"
Loop While (lRow < LastRow + 1)
End With
End Sub
"Dastard" wrote in
message ...
yeah .. u r right , data is incorrect
lemme alter it ...
Done
check the attachement now
thanks and waiting
Regards
+-------------------------------------------------------------------+
|Filename: Test.zip |
|Download: http://www.excelforum.com/attachment.php?postid=4756 |
+-------------------------------------------------------------------+
--
Dastard
------------------------------------------------------------------------
Dastard's Profile:
http://www.excelforum.com/member.php...o&userid=34406
View this thread: http://www.excelforum.com/showthread...hreadid=541843