+ Reply to Thread
Results 1 to 11 of 11

Looking for a rolling max count of item usage

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Looking for a rolling max count of item usage

    I have included an example of what I am hoping for.
    I am trying to get a maximum number of items used in a rolling(hope that term works) time period.
    (Meaning that Jan 1, 2013-Feb 14, 2013 would be one example of a 45 day period, Jan 2, 2013-Feb 15, 2013 would be another... etc..)
    The item period's length would be specified in 'Item List'! D1
    with the results from each sheet displayed in 'Item List'! C4:E4

    This is 1 item's usage out of a 3500 item list. I am hoping to use the result of this on all 3500 items.

    Thanks for any help you can give,
    Mike
    Attached Files Attached Files

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking for a rolling max count of item usage

    Hi

    Can you explain a little more pls?

    45 days starting from when?

    Can you tell us which is the expected result for your first sheet and why?
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Looking for a rolling max count of item usage

    That is the problem. I would like to know the highest total from ALL possible 45(or whatever period length chosen) day periods. I don't want to make 1050 (365*3 - 45)separate countifs to account for each possible 45 day period in each 3 year sheet.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking for a rolling max count of item usage

    My question was this.

    ...Can you tell us which is the expected result for your first sheet and why?
    Is it 28 ??

  5. #5
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Looking for a rolling max count of item usage

    largest # I can find (manual counting) is rows 35-49 with a total count of 48

    Mike

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Looking for a rolling max count of item usage

    Look Mike.

    I am the one that try to helps you and you are the one that you need help.

    So now it looks like to beg you to give me(us) more informations for helping you.

    I asked twice: Which is the expected result and why, trying to understand what do you have in your mind.

    So i wish you good luck.

  7. #7
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Looking for a rolling max count of item usage

    I did not mean to offend.
    I thought I was giving the the answer you needed.

    I have made some changes to the 'Item List' sheet, making it give the answer from the '2007-09' sheet.
    I also did the same for the '2010-12' sheet

    My method is rather crude, and I don't see how it would work for actual sheet I am working with, that has 3500 items to count.

    Mike
    Attached Files Attached Files
    Last edited by Befuddled; 03-15-2013 at 08:22 PM.

  8. #8
    Registered User
    Join Date
    01-14-2013
    Location
    Louisiana
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Looking for a rolling max count of item usage

    I could not figure it out , so I decided to cheat , and write a custom function.

    a couple of things you need to know.
    file must be saved as an .xlxm
    dates must be sorted smallest to largest on sheets

    copy the code below, open vba alt & F11.
    click insert then module
    paste the code into it

    the name of the function is rollingcount and is under userdefined functions.

    I attached the file that i was working with. if you click on the cell with the formula and then Fx you can see the required arguments.

    i hope this helps, and if you need anything else just let me know.

    Option Explicit
    
    Function RollingCount(WorksheetName As String, Interval As Long, Criteria As String, CriteriaCol As Long, Optional FirstDate As Range) As Long
    
        Application.Volatile
        
        Dim WsN As Worksheet
        
        Dim lFinalRow As Long
        Dim i As Long
        Dim lTempCount As Long
        Dim lMaxCount As Long
        
        Dim dStartDate As Date
        Dim dEndDAte As Date
    
        Set WsN = ThisWorkbook.Worksheets(WorksheetName)
        lFinalRow = WsN.Cells(Rows.Count, 1).End(xlUp).Row
    
        dStartDate = CDate("1/1/" & Year(WsN.Range("A4")))
        dEndDAte = dStartDate + Interval
            
        lTempCount = 0
        lMaxCount = 0
        RollingCount = 0
        
        For i = 4 To lFinalRow
        
            Select Case WsN.Cells(i, 1).Value
                
                Case dStartDate To dEndDAte
                    If (StrComp(Trim(Criteria), Trim(WsN.Cells(i, CriteriaCol).Value), vbTextCompare) = 0) Then
                        lTempCount = lTempCount + 1
                    End If
                
                Case Else
                    i = i - 1
                    If lTempCount > lMaxCount Then
                        lMaxCount = lTempCount
                        lTempCount = 0
                    End If
                    dStartDate = dEndDAte + 1
                    dEndDAte = dStartDate + Interval
                    
            End Select
    
        Next i
        If lTempCount > lMaxCount Then lMaxCount = lTempCount
        RollingCount = lMaxCount
    End Function
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Looking for a rolling max count of item usage

    I will try that.

    Thanks for helping me

    Mike

  10. #10
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Looking for a rolling max count of item usage

    For some reason, on your attached file, the total on the "2010-2012" sheet for 45 days says 44, when it should be 116.
    I have been playing with this for a little bit, and don't understand where the total of 44 is coming from
    I changed all the entries to a QTY of 1,and then tried a 2 in every entry, and the total that the formula spits out (in cell D10) doesn't change from 44.


    Mike

+ 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