+ Reply to Thread
Results 1 to 6 of 6

Need macro that calculates two formula but displays only one of them in column

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    United,States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Need macro that calculates two formula but displays only one of them in column

    Hello Excel experts. I am one month into learning VBA code and syntax. I hit a wall. I want a macro that calculates the average difference between two rows in neighboring columns. More specifically after 21 lines/rows of the difference value I want the average to begin calculation. What I want is to display a moving average of this value and that is my problem. I do not want to create the moving average in another column. As time goes on the data set will get bigger rather quickly and creating a separate column just for the moving average will add unnecessary data to the growing file.

    Thank you for reading. Thank you in advance for your thoughts and expertise
    Attached Files Attached Files
    Last edited by jro4; 06-06-2013 at 02:23 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need macro that calculates two formula but displays only one of them in column

    Try this macro:
    Please Login or Register  to view this content.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    06-05-2013
    Location
    United,States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need macro that calculates two formula but displays only one of them in column

    ForumMacro.xlsmp24leclerc: Thank you! One thing though. I made just a generic column titled "average" on the spreadsheet with a average(E2:E23). Formatted it to 3 decimal places. Compared it to the value the macro you wrote calculated. They seem to be close, and then the values vary wildly. For some reason the macro fills cells 1-20 with a value and I think this is the cause for error.

    I attached an updated .xlsm showing this.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need macro that calculates two formula but displays only one of them in column

    OK, I see the difference. Try this one:
    Please Login or Register  to view this content.
    There should be a better way to do it but at least it works.

  5. #5
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Need macro that calculates two formula but displays only one of them in column

    OK, I see the difference. Try this one:
    Please Login or Register  to view this content.
    There should be a better way to do it but at least it works.

  6. #6
    Registered User
    Join Date
    06-05-2013
    Location
    United,States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need macro that calculates two formula but displays only one of them in column

    Nice work. Thank you!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1