Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loop thru sheets copy and then paste in other sheet | Excel Programming | |||
Loop through sheets and get number of records per sheet | Excel Programming | |||
Loop through sheets & filter main sheet using sheet name | Excel Programming | |||
How to calculate average from large dataset in several sheets? | Excel Worksheet Functions | |||
calculate totals of 5 sheets on to 6th sheet. | Excel Worksheet Functions |