Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to use the average function in the row after the last row of data in
column B that calculates the average of range (B10:last cell of data in that column). Then I need to fill that row to the right with that same average function, stopping the fill at the last column of data. This spreadsheet for my teachers will vary in size and my novice ability with VB has me stuck. I would really appreciate any help with this. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Public Sub ProcessData()
Dim LastRow As Long Dim LastCol As Long With ActiveSheet LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row LastCol = .Cells(10, .Columns.Count).End(xlToLeft).Column .Cells(LastRow + 1, "B").Resize(, LastCol - 1).Formula = "=AVERAGE(B10:B" & LastRow & ")" End With End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "VistaOnMyMac :)" <VistaOnMyMac wrote in message ... I need to use the average function in the row after the last row of data in column B that calculates the average of range (B10:last cell of data in that column). Then I need to fill that row to the right with that same average function, stopping the fill at the last column of data. This spreadsheet for my teachers will vary in size and my novice ability with VB has me stuck. I would really appreciate any help with this. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
Thank you so much. It worked great! How would I add formatting tasks to the same cells. For example: ..NumberFormat = "0.0" |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Public Sub ProcessData()
Dim LastRow As Long Dim LastCol As Long With ActiveSheet LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row LastCol = .Cells(10, .Columns.Count).End(xlToLeft).Column With .Cells(LastRow + 1, "B").Resize(, LastCol - 1) .Formula = "=AVERAGE(B10:B" & LastRow & ")" .NumberFormat = "0.0" End With End With End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "VistaOnMyMac :)" wrote in message ... Bob, Thank you so much. It worked great! How would I add formatting tasks to the same cells. For example: .NumberFormat = "0.0" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculating an average | Excel Worksheet Functions | |||
Calculating Average | Excel Discussion (Misc queries) | |||
Calculating an average using VBA | Excel Programming | |||
Calculating the average | Excel Discussion (Misc queries) | |||
Calculating Average on variable sized datasets w/VBA | Excel Programming |