View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default 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)"