# how to create formula with vba

1. ## how to create formula with vba

Hi!

In one sheet I have data, and in another I calculate minimum, maximum and average of that data for last two months. At the beginning of the new month I manually change the range for the new month. can I do that somehow automatically with vba?

so, in example, the december should became january with minimum, maximum and average from Sheets("data").Range("b255:b275")  Register To Reply

2. ## Re: how to create formula with vba

maybe so (see attachment)  Register To Reply

3. ## Re: how to create formula with vba

this works in example file. but in real file I have several years, so this formula would, I think, consider Decembers from all years and not just from last that I need.

and my question was is it possible to create ie. to calculate this formula with vba, because in the example you gave me,I still need to manually change formula for next month.  Register To Reply

4. ## Re: how to create formula with vba

Hi!
Is there any way I can rewrite the following code so it works but not in R1c1 notation. ``Please Login or Register  to view this content.``
I also tried this: ``Please Login or Register  to view this content.``
but it is not working.
Can this be done differently?  Register To Reply

5. ## Re: how to create formula with vba

And if so? Formulas in the green cells recalculate the maximum, minimum and average values over the last two months, depending on the date in cell F1.  Register To Reply

6. ## Re: how to create formula with vba

When I open file error #NAME? appears in sheet "count" cells A1, A2, and in the whole column C.

=ДАТАМЕС(F1;-2) I think it is because of this formula. I don't have it in excel 2003  Register To Reply

7. ## Re: how to create formula with vba

Sorry, this function from Russian local version. Write down the formula in cell A1:
=EDATE(F1,-2)
in cell A5:
=EDATE(F1,-1)

This function is available in the Excel 2003 after connecting Analysis ToolPack add-in.  Register To Reply

8. ## Re: how to create formula with vba

PHP Code:
``` Sheets("count").Range("C5")="=MIN(data!B2241:B2261)"  ```  Register To Reply

9. ## Re: how to create formula with vba

PHP Code:
``` Sheets("count").Range("C5")="=MIN(data!B2241:B2261)"  ```  Register To Reply

10. ## Re: how to create formula with vba

----------  Register To Reply

11. ## Re: how to create formula with vba

as an option (with macro and formulas)  Register To Reply