Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula req for macro
I need a macro which calculates the average for each column, tried the
following code, but didn't work out activesheet.cells(1,1).formulaR1C1="=Average(R[maxrow]C:R[-2]C)" |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula req for macro
I presume you calculate maxrow somewhere else.
Try this: activesheet.cells(1,1).formulaR1C1="=Average(R[" & maxrow & "]C:R[-2]C)" You will run into a problem with this because your formula is trying to go up 2 rows from activesheet.cells(1,1) and it can't do that. "Gautam" wrote: I need a macro which calculates the average for each column, tried the following code, but didn't work out activesheet.cells(1,1).formulaR1C1="=Average(R[maxrow]C:R[-2]C)" |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula req for macro
Assuming your data for each column starts in row 2 and you want the answer
in row 1. Sub averagecolumns() For i = 1 To 8 'num columns Cells(1, i) = Application.Average(Columns(i)) Next i End Sub -- Don Guillett SalesAid Software "Gautam" wrote in message ups.com... I need a macro which calculates the average for each column, tried the following code, but didn't work out activesheet.cells(1,1).formulaR1C1="=Average(R[maxrow]C:R[-2]C)" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
formula in macro | Excel Worksheet Functions | |||
Formula in macro causes macro to fail | Excel Programming | |||
Formula in a Macro | Excel Programming | |||
Formula expected end of statement error, typing formula into cell as part of VBA macro | Excel Programming | |||
Help With Formula and Macro Please | Excel Programming |