+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    01-12-2009
    Location
    Mesa, AZ
    MS-Off Ver
    Excel 2003
    Posts
    4

    Recognizing, counting, and displaying duplicates

    I work in the fitness center of a large senior community that keeps a strict reservation schedule for a certain piece of equipment.
    The users sign up with their address on a sheet of paper early in the week and when they arrive they highlight their names to signify they were there.
    My boss has been noticing an increasing number of no shows.

    She would like me to keep track of the addresses that aren't showing up on a consistent basis.

    I would like to create one Excel sheet in which data can be entered on a daily basis.
    For example here are the dates and their numbered addresses:
    12/1/2008 12/2/2008 12/3/2008
    1944 1944 1944
    2770 2770 2770
    868 868 868
    2030 2030 2030
    1944 1944 1944
    2770 2770 2770
    868 868 868
    2030 2030 2030
    445 445 445

    On the next sheet I would like to perform an analysis of these numbers.
    I would title every two columns with the week and the date.
    The first column in each week would display the duplicate address #s.
    The second column would display how many times the address came up as a no show that week.

    I would like to organize it this way:
    Week 1 (Date-Date) Week 2 (Date-Date) Week 3 etc
    #s Freq #s Freq #s Freq
    1944 3 1927 2 361 5
    2009 4 1492 5 1254 7

    My question is:
    Is this type of data analysis too complicated for simple functions?
    If not, what kinds of functions can I use?

    I am not versed in Macros or Basic programming.

  2. #2
    Valued Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    949

    Workbook?

    I'm sure you can see by looking at your post, it's very difficult to decipher the data as you've listed it. Posting it that way also means that if one of us is going to work on it, we have to copy everything over to get started.

    Please post an example workbook.

    mew!
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  3. #3
    Registered User
    Join Date
    01-12-2009
    Location
    Mesa, AZ
    MS-Off Ver
    Excel 2003
    Posts
    4

    Example Workbook

    Here is an example workbook.

    The first sheet is the raw data which would be inputted on a daily basis.
    The numbers indicate the address numbers of gym members who did not show up for their appointments.

    The second sheet is where I would like the data analyzed.
    I would like the first column of each Week section to list each duplicate address number and the second column would list how many duplicates there were for each number.

    Any ideas?
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    949

    More of my - bash VBA over the head - style code.

    Maybe...
    Code:
    Option Explicit
    
    Private Sub CommandButton1_Click()
    
    
    
    'Sheets("Duplicate Checking").cells(C4)
    Dim Icountera As Integer
    Dim Icounterb As Integer
    
    Dim Icounterxx As Integer
    Dim Icounteryy As Integer
    
    Dim Icounterx As Integer
    Dim Icountery As Integer
    
    Dim Vcellw As Variant
    Dim Vcellz As Variant
    
    Icountera = 1
    Icounterb = 2
    Icounterx = 1
    Icountery = 4
    Icounterxx = 1
    Icounteryy = 4
    
    For Icounterxx = 1 To 7
    
    For Icounteryy = 4 To 15
    
    Icountera = 1
    
    
    For Icounterx = 1 To 7
        
        For Icountery = 4 To 15
        
            Vcellw = Cells(Icounteryy, Icounterxx)
            Vcellz = Cells(Icountery, Icounterx)
                If Vcellw = Vcellz Then
                    Icountera = Icountera + 1
                End If
                      
        Next Icountery
           
    Next Icounterx
    
    If Icountera > 1 Then
        
        Icounterx = 1
        Icountery = 1
        For Icounterx = 1 To 84
        
        If Sheets("weekly data").Cells(Icounteryy, Icounterxx) = Sheets("Duplicate Checking").Cells(2 + Icounterx, 1) Then
            Icountery = Icountery + 1
        End If
        Next Icounterx
        
        If Icountery = 1 Then
            Sheets("Duplicate Checking").Cells(1 + Icounterb, 1) = Sheets("Weekly Data").Cells(Icounteryy, Icounterxx)
            Sheets("Duplicate Checking").Cells(1 + Icounterb, 2) = Icountera - 1
            Icounterb = Icounterb + 1
        End If
    End If
    
    Next Icounteryy
    
    Next Icounterxx
    
    ' week 2 starts here
    
    Icountera = 1
    Icounterb = 2
    Icounterx = 8
    Icountery = 4
    Icounterxx = 8
    Icounteryy = 4
    
    For Icounterxx = 8 To 14
    
    For Icounteryy = 4 To 15
    
    Icountera = 1
    
    For Icounterx = 8 To 14
        
        For Icountery = 4 To 15
        
            Vcellw = Cells(Icounteryy, Icounterxx)
            Vcellz = Cells(Icountery, Icounterx)
                If Vcellw = Vcellz Then
                    Icountera = Icountera + 1
                End If
                      
        Next Icountery
           
    Next Icounterx
    
    If Icountera > 1 Then
        
        Icounterx = 1
        Icountery = 1
        For Icounterx = 1 To 84
        
        If Sheets("Weekly Data").Cells(Icounteryy, Icounterxx) = Sheets("Duplicate Checking").Cells(1 + Icounterx, 3) Then
            Icountery = Icountery + 1
        End If
        Next Icounterx
        
        If Icountery = 1 Then
            Sheets("duplicate checking").Cells(1 + Icounterb, 3) = Sheets("weekly data").Cells(Icounteryy, Icounterxx)
            Sheets("Duplicate Checking").Cells(1 + Icounterb, 4) = Icountera - 1
            Icounterb = Icounterb + 1
        End If
    End If
    
    Next Icounteryy
    
    Next Icounterxx
    
    ' week 3 starts here
    
    Icountera = 1
    Icounterb = 2
    Icounterx = 15
    Icountery = 4
    Icounterxx = 15
    Icounteryy = 4
    
    For Icounterxx = 15 To 21
    
    For Icounteryy = 4 To 15
    
    Icountera = 1
    
    For Icounterx = 15 To 21
        
        For Icountery = 4 To 15
        
            Vcellw = Cells(Icounteryy, Icounterxx)
            Vcellz = Cells(Icountery, Icounterx)
                If Vcellw = Vcellz Then
                    Icountera = Icountera + 1
                End If
                      
        Next Icountery
           
    Next Icounterx
    
    If Icountera > 1 Then
        
        Icounterx = 1
        Icountery = 1
        For Icounterx = 1 To 84
        
        If Sheets("Weekly Data").Cells(Icounteryy, Icounterxx) = Sheets("Duplicate Checking").Cells(1 + Icounterx, 5) Then
            Icountery = Icountery + 1
        End If
        Next Icounterx
        
        If Icountery = 1 Then
            Sheets("Duplicate Checking").Cells(1 + Icounterb, 5) = Sheets("Weekly Data").Cells(Icounteryy, Icounterxx)
            Sheets("Duplicate Checking").Cells(1 + Icounterb, 6) = Icountera - 1
            Icounterb = Icounterb + 1
        End If
    End If
    
    Next Icounteryy
    
    Next Icounterxx
    
    
    End Sub
    Your information is the same for all three weeks, confused the hell out of me when I was trying to figure out why all three weeks worth of answers came out the same.

    EDIT:
    Could change this so that it looped around week to week if you have a pile more weeks worth of data, but I set it up this way cause it's easier to understand, and because you didn't say your sheet would be bigger than this.
    Attached Files Attached Files
    Last edited by mewingkitty; 01-19-2009 at 08:04 PM.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  5. #5
    Registered User
    Join Date
    01-12-2009
    Location
    Mesa, AZ
    MS-Off Ver
    Excel 2003
    Posts
    4

    Unsure how to use that code

    How do I apply all of that code?
    Is that Basic?

  6. #6
    Valued Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    949

    Aye aye captain

    Yup, that's VBA.

    Check out the attachment, see if it returns the results correctly. I generally write this stuff in my spare time at work, so I don't have a lot of time at that point to check for possible glitches. I do however have a couple of my IM addresses linked to this site, so if you'd like a hand getting it running on your spreadsheet, feel free to send me a "mew" and I'll help you out.

    mew!

    EDIT:
    Also please let me know if this is going to be limited to a 3 week schedule of if it needs to run for an indefinite number of weeks until encountering blanks.

    mew mew!
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  7. #7
    Registered User
    Join Date
    01-12-2009
    Location
    Mesa, AZ
    MS-Off Ver
    Excel 2003
    Posts
    4

    Thank you.

    I'll try it tomorrow morning.
    Thanks Lady Mew!

  8. #8
    Valued Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    949

    Your welcome

    So yeah, your welcome,
    and let me know if you need anything changed on that, cause I only set it to go through three weeks worth. I could make it have one loop and loop it until there are blank cells found, but it sounded like you only needed the three weeks analyzed, so I made three loops that are all hard written in with co-ordinates.

    and

    I'm a kitty.
    Not all kitties are ladies.

    mew!
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  9. #9
    Valued Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    949
    Wowzers.

    K so made some revisions.

    Added a counter at the beginning to determine how many weeks worth of data are present.

    Cut the rest of the formula down to one loop, which increments the integers each time a loop completes, so that it goes from week to week without fixed numbers for each.

    Included a couple notes in the code to hopefully make it a little clearer how it works, if you need to change anything later.

    Code:
    Option Explicit
    
    Private Sub CommandButton1_Click()
    
    'Sheets("Duplicate Checking").cells(C4)
    
    
    Dim Weeks As Integer
    Dim weekcount1 As Integer
    Dim daycount As Integer
    
    daycount = 0
    weekcount1 = 1
    Weeks = 0
    
    ' This checks for data in order to determine how many weeks are present.
    ' makes it run somewhat faster, there's another way to do this, but frankly,
    ' I still don't understand it, so I do it this way.
    For weekcount1 = 1 To 100
        If Cells(4, weekcount1) > 0 Then
            daycount = daycount + 1
        End If
        If daycount = 7 Then
            Weeks = Weeks + 1
            daycount = 0
        End If
    Next weekcount1
            
    
    Dim ZZ As Integer
    
    Dim AA As Integer
    Dim BB As Integer
    Dim CC As Integer
    Dim DD As Integer
    
    Dim Icountera As Integer
    Dim Icounterb As Integer
    
    Dim Icounterxx As Integer
    Dim Icounteryy As Integer
    
    Dim Icounterx As Integer
    Dim Icountery As Integer
    
    Dim Vcellw As Variant
    Dim Vcellz As Variant
    
    AA = -6
    BB = 0
    CC = -1
    DD = 0
    
    For ZZ = 1 To Weeks
    
    AA = AA + 7
    BB = BB + 7
    CC = CC + 2
    DD = DD + 2
    
    Icountera = 1
    Icounterb = 2
    Icountery = 4
    Icounteryy = 4
    
    For Icounterxx = AA To BB
    
    For Icounteryy = 4 To 15
    
    Icountera = 1
    
    'This is where the number of duplicates are counted.
    For Icounterx = AA To BB
        
        For Icountery = 4 To 15
        
            Vcellw = Cells(Icounteryy, Icounterxx)
            Vcellz = Cells(Icountery, Icounterx)
                If Vcellw = Vcellz Then
                    Icountera = Icountera + 1
                End If
                      
        Next Icountery
           
    Next Icounterx
    
    ' This is where repeat listings are checked for, and where the program determines
    ' which cell to place numbers in.
    ' Changing the 1 under this paragraph will change the number of duplicates
    ' required for a number to be listed, IE if you only wanted instances
    ' higher than 3, you would change it to 4
    If Icountera > 1 Then
        
        Icounterx = 1
        Icountery = 1
        For Icounterx = 1 To 84
        
        If Sheets("weekly data").Cells(Icounteryy, Icounterxx) = Sheets("Duplicate Checking").Cells(2 + Icounterx, CC) Then
            Icountery = Icountery + 1
        End If
        Next Icounterx
        
        If Icountery = 1 Then
            Sheets("Duplicate Checking").Cells(1 + Icounterb, CC) = Sheets("Weekly Data").Cells(Icounteryy, Icounterxx)
            Sheets("Duplicate Checking").Cells(1 + Icounterb, DD) = Icountera - 1
            Icounterb = Icounterb + 1
        End If
    End If
    
    Next Icounteryy
    
    Next Icounterxx
    
    Next ZZ
    
    End Sub
    EDIT:
    There's a couple numbers in there you may have to change. There's a pair of "4 to 15" loops, those are based on the information being in rows 4 to 15. If you have information in rows farther down than that, you'll need to change the "15"s to the row number you need checked to. Also with that, there's a loop with an 84 in it. That is based on checking 84 times for a duplicate number, so if you're going to increase the number of cells copied, you'll need to increase it too.

    It doesn't have to be exact, you could change the 15's and the 84 to 10000, it'd just take a lot longer to run.

    There's a way to make Ranges such as those dependant upon whether or not there is information in them, I just don't really get how to do it yet.

    mew.
    Attached Files Attached Files
    Last edited by mewingkitty; 01-20-2009 at 02:10 PM.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

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.2.0