Sub PutFormula()
Range("B3:B25").FormulaR1C1 = "=Average(RC3:RC137)"
End Sub
Sub PutFormula2()
Worksheets("Sheet1").Range("B3:B25").FormulaR1C1 =
"=Sheet3!Average(RC3:RC137)"
End Sub
This procedure places the appropriate formula into each cell in the range
B3:B25
No loop required.
The first simply uses the active sheet.
The second places th eformula on a sheet that does not need to be the active
sheet....and I also set the formula to point to a different sheet
--
Patrick Molloy
Microsoft Excel MVP
----------------------------------
"Lena5il " wrote in message
...
Hi all,
I need to calculate an average in VBA excel.
I know only this form of calculation:
Worksheets(2).Cells(3, 2).Value = "=Average(Sheet1!C3:C137)"
But I need to calculate this for few columns and rows, hence I want to
use a loop. But I don't know how to write this formula with a variable
inside.
Help me, please,
Lena
---
Message posted from http://www.ExcelForum.com/