+ Reply to Thread
Results 1 to 12 of 12

sumif issue

Hybrid View

  1. #1
    Registered User
    Join Date
    03-17-2006
    MS-Off Ver
    2007
    Posts
    93

    sumif issue

    Spent last couple hours searching, no luck. (did find couple other solutions to unrelated problems I needed help with, though!)



    Have:

    400 jobs per day
    assigned to 200 people per day
    in 12 different cities
    each city has it's own tab
    each day has different set of technicians working these jobs
    each job has different assigned point value.




    I need to pull to a summary tab:

    the technician #
    then
    sum the total of assigned points to that technician
    then
    sum the completed points by that technician.





    I've done this by creating a list of tech #'s for the formula to read first, but in this case the list of tech #'s is ever changing and way too dynamic to keep updating every day, so I would like it to read all the tech #'s working on that day and create it's own list.

    If I can get help with that, I can do the second and third part as I have done in the past.

    One last oddity, a technician can be working in two different cities on a given day so his tech # would be on two or more tabs.

    I have an example workbook - if needed I (think) I can attach.
    Better to be roughly right than exactly wrong, unless you are using Excel.

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

    Response

    You might be better doing this one by macro which searches all the tabs and compiles the list on the summary tab depending upon what it finds. I guess that you will need to be careful that any one technician is given more than one ID on the separate tabs - even a slight difference in a way that the name was written would be enough to produce confusing results.

  3. #3
    Registered User
    Join Date
    03-17-2006
    MS-Off Ver
    2007
    Posts
    93
    OK... I've recorded a macro just for fun to do some mouse clicks, but have not done anything else, like actually writing code.

    Where to start that learning process?

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

    Response

    You'll need something more that that you can record if you want to loop through all the sheets. If you want to find out more, have a look at the for...next loop in VBA help. (Alt F11 then help).

    Are you able to attach a copy of the workbook so that we can see the detail of what you are trying to achieve? - it should be then possible to give more useful advice.

  5. #5
    Registered User
    Join Date
    03-17-2006
    MS-Off Ver
    2007
    Posts
    93
    Yes sir.

    I have this small workbook as example.

    First two tabs are two cities with the end of day info that I will be using.


    Summary tab has headers with a description of what I need them to have in the columns.

    Of course, this will be expanded to 12 tabs, but I can handle that part.
    Attached Files Attached Files
    Last edited by redneck joe; 11-18-2006 at 05:03 PM.

  6. #6
    Forum Contributor
    Join Date
    07-05-2006
    Location
    Canada
    MS-Off Ver
    2003, 2007
    Posts
    581
    You can try this macro.

    Basically, it loops through all your sheets to gather data (excluding the one specified in the SUMMARY_NAME constant.

    It then puts the summary information in the SUMMARY_NAME sheet.

    It makes a couple of assumptions:

    First, that your employee ids are all numeric and below 50,000. You can adjust this upward, but it won't work with non-numeric employee ids.

    Second, that your description for being done is "complete".

    Third, the sheet you want to skip is "summary".

    Fourth, the columns listed in the example are the columns that you are actually using.

    Plus, some other little things in comments.

    Option Explicit
    
    Const MAX_EMPLOYEE_ID = 50000
    Const DESC_COMPLETE = "complete"
    Const SUMMARY_NAME = "summary"
    
    Public Sub Summarize()
      Dim WS As Worksheet
      Dim Start As Long
      Dim Finish As Long
      Dim Data(MAX_EMPLOYEE_ID, 1) As Long
      Dim i As Long
      Dim j As Long
      Dim current As Long
    
      'Gathering data... this goes through all sheets except the SUMMARY
      'sheet.
      For Each WS In Worksheets()
        If WS.Name <> SUMMARY_NAME Then
          Start = 2   'Assuming each sheet's data starts on Row 2
          Finish = WS.Range("A65536").End(xlUp).Row
              
          For i = Start To Finish
            With WS
              current = .Cells(i, 1)
              If (.Cells(i, 3) = DESC_COMPLETE) Then
                Data(current, 1) = Data(current, 1) + .Cells(i, 4)
              End If
              Data(current, 0) = Data(current, 0) + .Cells(i, 4)
            End With
          Next i
        End If
      Next
    
      'This puts the data in the SUMMARY sheet
      'For reference:
      '  i represents the row in our Data array.
      '  j represents the row in output, starting with row 2.
      j = 2
      For i = 0 To MAX_EMPLOYEE_ID
        If (Data(i, 0) <> 0 Or Data(i, 1) <> 0) Then
          With Worksheets(SUMMARY_NAME)
            .Cells(j, 1) = i
            .Cells(j, 2) = Data(i, 0)
            .Cells(j, 3) = Data(i, 1)
          End With
          j = j + 1
        End If
      Next i
    End Sub
    Scott

+ 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