+ Reply to Thread
Results 1 to 15 of 15

counting and percentages in multiple sheets

Hybrid View

  1. #1
    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,

    To test for a string value the UDF would be...
    Public Function GetTextCnt(RefCell_Addx As String,  Text_Value As String) As Long
    
      Dim N As Long
      Dim Wks As Worksheet
      
        For Each Wks In Worksheets
          If Wks.Range(RefCell_Addx).Value = Text_Value Then N = N + 1
        Next Wks   
    
        GetTextCnt = N
        
    End Function
    Sincerely,
    Leith Ross

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

    what language is this code? VB?

  3. #3
    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 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

  4. #4
    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?

  5. #5
    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,

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

    Sincerely,
    Leith Ross

  6. #6
    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?

  7. #7
    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,

    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.
    Public Function GetTextCnt(RefCell_Addx As String,  Text_Value As String) As Long
    
      Application.Volatile
    
      Dim N As Long
      Dim Wks As Worksheet
      
        For Each Wks In Worksheets
          If Wks.Range(RefCell_Addx).Value = Text_Value Then N = N + 1
        Next Wks   
    
        GetTextCnt = N
        
    End Function
    Sincerely,
    Leith Ross

+ 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