+ Reply to Thread
Results 1 to 17 of 17

Countif + SumByColor

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    Ruse
    MS-Off Ver
    Excel 2003
    Posts
    22

    Countif + SumByColor

    Hello all,

    I need help in the following case:

    I have 60 workers which are working on 4 different shifts (each shift is identified by the color of the cell, see the legend in the upper left corner) and are using 3 different buses to get to work (bus M1, M2 and M3).

    What I want to have automatically below the table is a counter which will tell me how many workers will use each type of bus per shift. For example:

    First shift
    M1: 2 workers
    M2: 10 workers
    M3: 0 workers

    Second shift:
    M1: 3 workers
    M2: 4 workers
    M3: 2 workers

    and so on.

    What I have so far included is a VB function "SumByColor" which sum cells based on their color, but I don't know how to make such complicate connection to get the wanted result. I was thinking about a possible way to combine "Subtotal" and "SumByColor" , so when I filter bus "M1" for example I will get this split of visible rows below the table. This is also a good solution, but can anyone help me to build it up? Thanks so much.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    How did you define the color of the workers.

    You do it manualy?

    If you make a column to define which shift it has to be, you can use pivot table. for your problem.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    09-04-2012
    Location
    Ruse
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Countif + SumByColor

    The color and the number inside which represents the hours on that day are defined manually, yes. After that the VB SumByColor function below will tell me how many people worked first, second, night or regular shift on that day. I just divide that by 8 to get the number of people, but I can't get the connection to the buses. The idea of this file is to create a shifts plan for the whole month and based on that in advance to prepare a daily schedule for the buses. I don't want to create another sheet for that because right now my supervisors in the production are using this format and to create shifts plan and record the hours manually at the end of each work day.

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    Please Login or Register  to view this content.
    There is no way to define that in a seperated column?

  5. #5
    Registered User
    Join Date
    09-04-2012
    Location
    Ruse
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Countif + SumByColor

    Maybe there is a way, yes but that means double work, correct?

  6. #6
    Registered User
    Join Date
    09-04-2012
    Location
    Ruse
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Countif + SumByColor

    Untitled.jpg

    Can we just make the following:

    I will filter the buses one by one.
    If I'm able to combine "subtotal" with "sumbycolor" I will get the needed result just like it is shown on the picture. Any ideas how to do that?

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    I should re-arange your data (like I showed you on sheet Output)

    After that you are able to make a pivot table of the data (like I showed you on the sheet PT)

    The column shift needs to be filled (manualy)

    See the attached file.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-04-2012
    Location
    Ruse
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Countif + SumByColor

    Thanks for the example. but I think in this case it is double work because I have to manually fulfill the data again in a separate sheet, is it correct? For example I don't know how you've made the connection between the data which is later used as a data source in sheet1.

  9. #9
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    you use my sheet output as your input file (or the format of my output sheet), you are able to use a pivot table.

    What about the result in the pivot table.

    Is this something you could work with?

    Does this give you the information you need (or do you need more or less information)?

  10. #10
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Countif + SumByColor

    I think this is what you want. I just threw in another condition for the sum that the row has to be visible.
    Attached Files Attached Files
    Despite the high cost of living, it remains very popular.

    Don't forget to mark threads SOLVED when you get an answer and rep all the geniouses that helped you today!

  11. #11
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Countif + SumByColor

    Well, it is not letting me edit my post so I'll just say here that I did notice the column 1 formulas were all pointing to the first shift for some reason, that is why you see all 1 instead of the numbers you should see for other shifts.

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    @hawkeye16

    Please try also to add the changes in the text, so other forummembers also can see what the given solution is?

    Can you add which cells you have changed?

  13. #13
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Countif + SumByColor

    He had a custom formula for SumByColor. It went through the range specified and used an if statement to check the background color after which it would add the cell to the sum. I just added another condition to the if statement to see if the row was visible so that when filtered it would only add the visible rows as he requested.

    I'll try to explain better in words in the future as the code is not something people look at right away.

  14. #14
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    @hawkeye16

    In which columns did you change a formula?

    I looked but couldn't find it.

    I expect the result 5 in the cell D78. (5 * 7)/8 = 5,25.

    The result now is 1.

  15. #15
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Countif + SumByColor

    That is because, as mentioned above, the column 1 formulas are all pointing to the first shift option for some reason, I did not feel like correcting and reuploading. Just change the sum formula they used to look at the correct shift cell and the values are correct. I did not change any formulas or anything on the original sheet, just added some code into the custom function that was there.

  16. #16
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    @Hawkeye16

    Thanks for the explaination.

    Now we can wait on the reply of the OP (sordid).

  17. #17
    Registered User
    Join Date
    09-04-2012
    Location
    Ruse
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Countif + SumByColor

    Hawkeye16

    This is exactly what I wanted, thank you so much! Thanks to oeldere too for all the support. I think it is solved now.

  18. #18
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif + SumByColor

    Thanks for the reply.

    You can add rep(utation) to the one who helped you by clicking on the star.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combining a Date Range COUNTIF and a general COUNTIF
    By jacobtom in forum Excel General
    Replies: 1
    Last Post: 09-15-2011, 05:06 PM
  2. [SOLVED] SumByColor(Rng)
    By JimMay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2006, 07:45 AM
  3. VBA defined function problem sumbycolor
    By Brian Matlack in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2006, 08:17 AM
  4. how to use sumbycolor fuction?
    By Ghauri in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-29-2005, 05:10 PM
  5. SumByColor Macro...
    By Murph in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-28-2005, 07:05 PM

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