+ Reply to Thread
Results 1 to 30 of 30

Formula for rolling back three months

  1. #1
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Formula for rolling back three months

    I have a spreadsheet I am creating to add attendance "points" for the previous 3 months. Each month of the year has a spearate spreadhsheet tab with the same spreadsheet. What I would like is at the end of each spreadsheet, it would calculate the points in each "point column" for the past three months.

    Example: There is a tab for each month on the spreadhseet. (January, February, March, April, etc). On each of these tab pages is a spreadhseet for that month. Columns AP, AR, AT etc are points for that person that day. Column BM I want to say "Total points for last three months." I would like this column to take the current date of whatever date it is when I open the spreadsheet, calculate the points for that month as well as the points for the previous 3 months, going back on the other months tabs.

    Can anyone help me with this?

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Formula for rolling back three months

    Attach a sample workbook and we can help you out....
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Formula for rolling back three months

    This user defined formula will sum identical ranges in the current and previous two sheets.

    Please Login or Register  to view this content.
    Add this to a new module in the VBA editor (Alt F11) and type =SumLastThreeMonths(A:A) for example in the latest of the three sheets.
    Martin

  4. #4
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    Here is a sample. It starts this month (December 2011). December I would like to show just this month. January the last two months rolling from the current dat. Starting in February and thereafter, The last three months rolling from the current date.

    I appreciate it!
    Sample attendance tracking 1.xls

    Sample attendance tracking 1.xls

  5. #5
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    ANy ideas?

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Formula for rolling back three months

    What about mrice's solution? It didnt work for you?

  7. #7
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    To be honest, I did not quite understand it. I am relatively new to Excel Programming. Do I go to the VBA editor and just copy and past that formula? How will it tell what the current date is?

    I appreciate it!

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Formula for rolling back three months

    Its better Mrice explains the code to you.

  9. #9
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    I appreciate any explanation/help. I am under a kind of time crunch. I reall y do appreciate everyone's help and sorry for my lack of understanding.

  10. #10
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Formula for rolling back three months

    It would be useful if you could put some data into your template and an expected result so that we can help more.

  11. #11
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    Try the attached.

    Hope this helps

    If you are using XL 2003 or prior Analysis ToolPak Addin needs to be activated to work EOMONTH. See the help XL file how to activate it.
    Attached Files Attached Files
    Last edited by Haseeb Avarakkan; 12-13-2011 at 02:05 PM.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  12. #12
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    As others I have attached a workbook with some data filled in of what I expect it to do. As stated before, I would like it to "roll backward" three months to calculate each person's attendance points. If you look at the page on December 2011, you will see that Jane SMith has .5 points rolling back three months from today's date. (12/14/11). Lance Armstrong has 1.5, again rolling back three months from todays date.

    I tried pluggin in the previously suggested formula, but got an error message even though I downloaded the toolpack.

    I appreciate any help/advice.
    Sample attendance tracking 1.xls

  13. #13
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    Any advice?

  14. #14
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Formula for rolling back three months

    Its not clear how you are specifying the date. Each tab relates to a month. So if I open the December tab during the month of February, are you expecting to see the sum of the points for each person for the months October to December inclusive or should today's February date be used in some sort of calculation?

  15. #15
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    That is a good point. What if there was a separate tab/sheet that indicated everyones name and their point value as of whatever date it is opend?

  16. #16
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    Well, here is what I was talking about. I added one page that would have everyone's point total three months rolling back from the current date. Disregard the three months rolling column at each month tab, I can change that to just a monthly total. Also, on the added employee point toal page I have a cloumn that would calculate FMLA days rolling back 12 months.

    I feel I am almost there. I appreciate greatly the help.

    anothersampleattendance.xls

  17. #17
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    Try the attached.

    Assume 1st day starts at column C & Total Points & Total FMLA column will be right after the last day in a month. Also assume each day will have 3 columns, Code - Ponts - Time Missed.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    I am getting a #VALUE error.

  19. #19
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    If you are on XL 2003 or prior Analysis ToolPak needs to be activated to work EOMONTH. Also need to define the names. Press CTRL+F3 & create those names to your workbook.

  20. #20
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    I downloaded all the toolpaks. I am not sure what you mean on "defining the names" I used CTRL +F3" over "Jane Doe" for example but it did not seem to do anything. I am sure that is not exactly what you meant.

    I appreciate your time and help.

  21. #21
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    What did you get when you open the file attached in Post#17? error or number?
    Last edited by Haseeb Avarakkan; 12-16-2011 at 04:49 PM.

  22. #22
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    error: #VALUE!

  23. #23
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    I am not sure why you are getting error, any way try this formula without any name in the attached sheet.

    Formula in 'Employee points and FMLA totals'!C5

    =SUMPRODUCT(SUMIF(INDIRECT("'"&{"September 2011","October 2011","November 2011"}&"'!A:A"),A5,INDIRECT("'"&{"September 2011","October 2011","November 2011"}&"'!"&ADDRESS(1,DAY(EOMONTH(CurrDate,{-3,-2,-1}))*3+3))))

    Are still gets error with this formula?

  24. #24
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    I get a "name" error for some reason

  25. #25
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    Quote Originally Posted by stryped View Post
    I get a "name" error
    That means you have not been activated Analysis ToolPak AddIn. See the below link how to activate it.

    Load the Analysis Toolpak

    Or,

    The attached version will work without Analysis TookPak. If you still get error with this file, I am sorry stryped. I don't know what is the issues.

    Hope this helps you.
    Attached Files Attached Files

  26. #26
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    I am now getting a run time error. I feel I am so close.

    When I enter data on the above spreadsheet, it does not calculate it. The totals on the "Totals" tab just stays the same.

  27. #27
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    I am also getting a run time error 1004?

  28. #28
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    Run time error gets because of the VBA code error. remove all VBA codes & Save As a new file. also make calculation mode to Automatic NOT manual.

  29. #29
    Registered User
    Join Date
    06-17-2011
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Formula for rolling back three months

    I am not sure what is wrong. It is set to automatic. Removed vba codes and re saved. Still not calculating on the "employee points and FMLA totals" tab.

    Here is what I have: Sample.xls

  30. #30
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Formula for rolling back three months

    To get the total, you will need a total column to be calculated on each tab. Use this formula in each tab of the column where says,

    Total Points for This Month:

    =SUMIF(C$4:CU$4,"points",C5:CF5)

    then copy down.

    in each tab Total FMLA Time Missed for Month:

    =SUMIF(C5:INDEX(5:5,MATCH("Total FMLA Time Missed for Month",$2:$2,0)-4),"FMLA",E5:INDEX(5:5,MATCH("Total FMLA Time Missed for Month",$2:$2,0)-2))

    copy down.

    Now should be OK.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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