+ Reply to Thread
Results 1 to 4 of 4

Average formula for a specific condition

  1. #1
    Registered User
    Join Date
    06-03-2008
    Posts
    3

    Average formula for a specific condition

    I have been asked at work to get some averages of data from an excel sheet. I have attached a sample workbook of the data i will be using.

    On Sheet1 is the data that will be looked at and on sheet2 is a sample of the results i need to achieve. I can get the data on sheet2 easy if i knew that data was static but in my case the data is going to be dynamic, so i don't know how many records each person is going to have each time if that person shows up in the record set at all. This rules out on static ranges to gather averages.

    So far what i came up with is i use a macro to copy all the "Names" column to sheet 2 and then filter that data so that each name is unique, sort like a "key" for looking up values. Now i need to get averages of "Total Hours" worked in sheet 1 and display it in sheet 2 for each "Name". I have a formula worked out and almost have it where i want it but cant seem to get the range of data i need to be looking at.

    I need to get the Average Of hours Worked Per Person Where "Wk End Date" is greater than 1/1/2008 and the "name" matches up with the name in sheet 2.

    I have... ( this formula doesnt figure in the dates yet.. any help would be appreciated on that part as well.)

    Please Login or Register  to view this content.
    but this code looks at the whole column of F:F in sheet 1 but i want the range in Column F where Column B equals a "Name" in Column A in Sheet 2.


    I figured if i can figure this formula out i can use it to get the Averages for the other information. I hope this isn't too confusing. If you need any other information let me know.
    Attached Files Attached Files
    Last edited by rrmacman; 07-31-2009 at 08:54 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Average formula for a specific condition

    see atached put your last date and refer to that i used f1
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Average formula for a specific condition

    Just another option. Could you use a Pivot Table?

    If it is based on a dynamic named ranged it only needs to be refreshed when the data changes and this is easily automated with a bit of VBA code, plut is adds more flexibility to quickly get different views of the data.

    See attached.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-03-2008
    Posts
    3

    Re: Average formula for a specific condition

    Both of these are really helpful, thank you very much. One thing though, the pivot table could work but might be very long as the "real" list has over 5000 distinct names. But i guess i can try it and give to my boss with both options and they can choose. Thanks again

    Edit:

    I guess a pivot table work as the names wont fit on the header row of the pivot table because it exceeds the limit
    Last edited by rrmacman; 07-31-2009 at 08:59 AM.

+ 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