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: 2,836
Default Loop through all sheets, calculate Average in K1 of each sheet

Mid afternoon; got into the office early and still not fully awake here. I
am trying to loop through all sheets and fine the average for numbers in a
range, which always starts in J2 (has a header) and goes down a variable
number of rows. I want to enter the average in Cell K1. This is what I have
so far.

Sub Aver()
Dim lastrow As Long

For Each sh In Worksheets
If (sh.Name) < "Summary Sheet" And (sh.Name) < "Alpha" And (sh.Name)
< "PSA Time Interval" And (sh.Name) < "Summary" Then
sh.Activate


With sh
lastrow = .Cells(.Rows.Count, "J").End(xlUp).Row
.Cells(lastrow, "K").Activate
'ActiveCell.Offset(0, 0).Select
Selection.End(xlUp).Select
ActiveCell.FormulaR1C1 = "=average(r2c:)" & lastrow
End With

End If
Next sh

End Sub

My macro is trying to calculate the average in column K, but I want to base
the average on Column J. Please help.

TIA,
Ryan---



 
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
Loop thru sheets copy and then paste in other sheet LuisE Excel Programming 2 August 7th 08 07:28 PM
Loop through sheets and get number of records per sheet Les Excel Programming 3 May 20th 08 05:10 PM
Loop through sheets & filter main sheet using sheet name Les Excel Programming 4 May 20th 08 02:39 PM
How to calculate average from large dataset in several sheets? Orf Excel Worksheet Functions 2 December 12th 05 10:59 AM
calculate totals of 5 sheets on to 6th sheet. salvo Excel Worksheet Functions 1 March 25th 05 06:58 AM


All times are GMT +1. The time now is 12:15 PM.

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

About Us

"It's about Microsoft Excel"