+ Reply to Thread
Results 1 to 15 of 15

counting and percentages in multiple sheets

  1. #1
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108

    counting and percentages in multiple sheets

    i apologize in advance for starting 3 threads in 1 day, but i thought each one was different enough from the last top warrant it's own thread.

    here's an example of what i am trying to do. i have 4 worksheets with various names. i have an 5th worksheet with a named list (TabNames) of the 4 worksheet names

    each of the 4 worksheets have cells with percentages in them.

    i would like to check a cell from each sheet and see if the percentage is equal to or above a certain %, for example anything equal to or above 90%. then return the number of cells that meets or exceeds that 90% criteria.

    so for example

    sheet1 sheet2 sheet3 sheet4
    A
    1 80% 91% 76% 82%
    2 80% 95% 92% 43%

    so checking cell A1 in list TabNames would return 1, and checking cellA2 would return 2.

    thanks...last topic today i promise just starting to learn about excel formulas...

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello kmfdm515,

    The easiest approach is to use a UDF (User Defined Function) to do this across multiple sheets. Here is the code and instructions on how to install and use the UDF.

    UDF Macro Code
    Please Login or Register  to view this content.
    Installing the UDF Code
    1. Copy the code above using CTRL+C
    2. Open your Workbook in Excel.
    3. Right Click on the Name Tab of any Worksheet.
    4. Click View Code in the pop up menu.
    5. Press ALT+I to activate the Insert menu.
    6. Press the letter m.
    7. Paste the code into the module using CTRL+V
    8. Save the UDF code using CTRL+S
    9. Press ALT+Q to return to Excel.

    Using the UDF
    This function takes 3 arguments:
    RefCell_Addx - A string indicating the cell you want to check
    Compare_Flag - A string indicating the type of compare to perform. There are five strings "<=", "<", "=", ">", ">="
    Percent_Value - Number expressed as a valid percentage.

    Example
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 01-22-2008 at 09:57 PM.

  3. #3
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108
    That is fantastic! Thank you so much!

    One more question...how do I edit that formula to make it conditional on some text in a certain cell on each sheets? like if i only want it to count sheets that have text "x" in cell C9, etc.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello kmfdm515,

    To test for a string value the UDF would be...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108
    thanks so much!

    what language is this code? VB?

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello kmfdm515,

    The language is VBA (Visual Basic for Applications). This is used by all the Office suite programs: Excel, Word, PowerPoint, Access, and Outlook.

    Sincerely,
    Leith Ross

  7. #7
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108
    expanding on this a bit, would it be possible to then list the sheet names in some cell and specify whether they met the criteria or not?

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello kmfdm515,

    You should start a new thread to get an answer to that question.

    Sincerely,
    Leith Ross

  9. #9
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108
    Thanks Leith, I'll do that.

    With these formulas you gave me, though...they aren't re-calculating after any changes are made to the numbers in the sheets, even after saving and re-opening my file. i have to manually go back to my cells with these formulas and press enter for every one to get them to re-calculate.

    am i missing something here?

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello kmfdm515,

    I forgot to add an important line of code to the macro. The line in blue makes sure the function gets recalculated whenever Excel recalculates the sheet.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  11. #11
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108
    Hi,

    That seems to work...when i make a change in another sheet, the formulas recalculate.

    but then...if i leave the sheet open for ~ 10 minutes...all the cells with these formulas go back to zero??? what is causing that?

  12. #12
    Forum Contributor
    Join Date
    09-25-2004
    Posts
    269
    May I see a sample of your workbook?

  13. #13
    Forum Contributor
    Join Date
    08-18-2004
    Posts
    108
    my workbook has like 100 worksheets so it's really huge. is posting it here necessary to determine what's causing that issue?

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello kmfdm515,

    The 10 minute time interval sounds like the default setting for the Auto Save. What I don't understand, and can't reproduce is the data loss after saving the workbook. You mention you have over 100 sheets in the workbook. Perhaps the problem is related to memory management. What version of Excel are you using?

    Sincerely,
    Leith Ross

  15. #15
    Forum Contributor
    Join Date
    09-25-2004
    Posts
    269
    Quote Originally Posted by kmfdm515
    my workbook has like 100 worksheets so it's really huge. is posting it here necessary to determine what's causing that issue?

    I might have a formula solution but then again you have 100 worksheets the calculation might be very slow..

+ 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