Results 1 to 15 of 15

counting and percentages in multiple sheets

Threaded View

  1. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    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
    Public Function GetPercentCnt(RefCell_Addx As String, Compare_Flag As String, Percent_Value As Double) As Long
    
      Dim N As Long
      Dim Wks As Worksheet
      
        For Each Wks In Worksheets
          Select Case Compare_Flag
            Case Is = "<="
              If Wks.Range(RefCell_Addx) <= Percent_Value Then N = N + 1
            Case Is = "<"
              If Wks.Range(RefCell_Addx) < Percent_Value Then N = N + 1
            Case Is = "="
              If Wks.Range(RefCell_Addx) = Percent_Value Then N = N + 1
            Case Is = ">"
               If Wks.Range(RefCell_Addx) > Percent_Value Then N = N + 1
           Case Is = ">="
              If Wks.Range(RefCell_Addx) >= Percent_Value Then N = N + 1
         End Select
        Next Wks
        
        GetPercentCnt = N
        
    End Function
    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
    'Sheet5 cell B1 has the formula 
      =GetPercentCnt("A1", ">=", 90%)
    
    'Sheet5 cell B2 has the the formula
      =GetPercentCnt("A2", ">=", 90%)
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 01-22-2008 at 09:57 PM.

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