View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
David David is offline
external usenet poster
 
Posts: 1,560
Default range average code

Hi Again,
Try this one:
Sub Avg6Again()
Range("B2").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(6, 0).Select
ActiveCell.Offset(0, 4).FormulaR1C1 = "=AVERAGE(R[-6]C[-4]:RC[-3])"
Loop
End Sub
--
David


"Peter Beach" wrote:

Hi saziz,

If you wanted a pure formula solution, try something like:

=IF(MOD(ROW(B1),6)=0,AVERAGE(OFFSET(A1,0,0,6,1))," ")

That will average the values in column A every 6 rows.

Just an idea.

Regards,

Peter Beach

"saziz" wrote in
message ...

Hi Folks,
I have a sheet with data in col. B & C 2500 rows.
I do average on every 6th. row down until 2,500 rows.
I find myself doing this quite often. Wondering if someone can help
me write a VBA code.

first range value is (B2:C7) and then next would be further 6 rows down
starting from (B8:C13) until where the data ends (about 2500 rows)

Thank you for your help.
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile:

http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=498143