+ Reply to Thread
Results 1 to 8 of 8

Correct syntax for function to find average based on background color of cells in range

  1. #1
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Correct syntax for function to find average based on background color of cells in range

    Good afternoon. I'm working on a workbook that will track staffing patterns.

    The workbook has three worksheets: Sheet1 "RCS", Sheet2 "HCT' and Sheet3 "Hidden". I've attached the workbook to this thread. The password for the form is "j".

    On Sheet3 "Hidden" I have two tables that are set up to collect the SUM of columns on Sheets1 "RCS" and Sheet2 "HCT". I'm finding the SUM of each range by way of the background color. I've set up the following formulas and when the "data collection tables" are in the same worksheets as the original information, the formula's work perfectly:

    The following functions are pulling data from Sheet1 "RCS" and placing them into a table in Sheet2 "Hidden"


    Please Login or Register  to view this content.
    The following functions are pulling data from Sheet1 "RCS" and placing them into a table in Sheet2 "Hidden"

    Please Login or Register  to view this content.
    I have two more functions that aren't working due to the fact that the source values are percentages and NOT plain numbers. The above functions work great for SUM but not for percentages. EXAMPLE--Let's say, 3 sub percentages it gives me the SUM of the 3 percentages (i.e. 85% + 100% + 100% = 285% instead of giving me 95%.

    Please Login or Register  to view this content.
    How might I use the following functions to find the average of the source fields instead of the SUM?

    I appreciate any feedback you might be able to offer to me. Thanks.

    Matthew
    Attached Files Attached Files
    Last edited by moosetales; 05-20-2014 at 03:03 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Correct syntax for function to find average based on background color of cells in rang

    Can you:

    1) upload a fully unlocked workbook
    2) specify exactly what cell has a formula you're using and what the desired result is in that specific cell over the value your formula is offering
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Correct syntax for function to find average based on background color of cells in rang

    Hi Matthew

    What do you wish to do if "Productivity" is blank...count it or skip it?

    If you wish to exclude it try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by jaslake; 05-20-2014 at 04:38 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Correct syntax for function to find average based on background color of cells in rang

    JERRY,

    I'll upload an unprotected version once I'm back from my daughters track meet. I'll explain a bit more then as well.

    John,

    Great question. I hadn't given it any thought since there is likely never going to be a time where the productivity will be blank. I guess if I had to choose I would opt for including it in the equation. Thanks.

    In the end I will be showing the totals in a userform that will be a summary of both services. Thanks.

    Matthew

    Matthew
    Last edited by JBeaucaire; 05-20-2014 at 05:17 PM.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Correct syntax for function to find average based on background color of cells in rang

    Hi Matthew

    To include use this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Correct syntax for function to find average based on background color of cells in rang

    Sheet2 "HCT" Column J contains subtotals of individual worker productivity (%). At any given time we may be tracking 3 to 7 employees so the number of subtotals that I will be averaging will vary. I need to average the subtotals to come up with a grand total for the productivity of all employees working within HCT services.

    Please Login or Register  to view this content.


    Sheet1 "RCS" Column I contains subtotals of individual worker productivity (%). At any given time we may be tracking 3 to 7 employees so the number of subtotals that I will be averaging will vary. I need to average the subtotals to come up with a grand total for the productivity of all employees working within RCS services.

    Please Login or Register  to view this content.


    The two lines of code above give me the SUM of all the percentages and not the average. Some how I need to figure out how to get the average % of all the subtotals. Hope this helps.

    Thanks.

    Matthew
    Attached Files Attached Files
    Last edited by JBeaucaire; 05-20-2014 at 10:14 PM.

  7. #7
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Correct syntax for function to find average based on background color of cells in rang

    Quote Originally Posted by jaslake View Post
    Hi Matthew

    To include use this
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    John,

    I'll give it a try. I guess I was posting when you posted this function. I'll be right back. Thanks.

    Matthew

  8. #8
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Correct syntax for function to find average based on background color of cells in rang

    John,

    Thanks once again for helping me put together the key elements that I was missing on the form. I'm pretty darn close to putting this out for a soft launch.

    I still have a few hiccups to correct but I am really pleased with the results thus far. The coding for the userform (click either of the Summary command buttons) works perfectly. I've attached a copy of it in mock form. Take care and talk soon.

    Matthew
    Attached Files Attached Files

+ 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. Macro to set value based on range of different cells with background color.
    By prem4u in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-28-2014, 12:55 PM
  2. Macro to copy rows based on background color of cells within a range of columns
    By jpitt916 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2013, 06:16 PM
  3. [SOLVED] Macro to copy rows based on background color of cells within a range of columns
    By Chrispelletier in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-19-2013, 01:30 PM
  4. [SOLVED] Sum and average cells based on background color
    By Kaitlynn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-22-2013, 12:51 PM
  5. [SOLVED] Find all cells with a specific background color then copy/paste to correct column
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-20-2012, 10:18 AM

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