+ Reply to Thread
Results 1 to 9 of 9

COUNTIF across all worksheets of the same workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    01-08-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    5

    COUNTIF across all worksheets of the same workbook

    I need to count the frequency/occurance of strings "Manager", "Clerk", "HR" etc. that occur in the exact same column in multiple worksheets of a single workbook.
    COUNTIF works ok on a single sheet query but the formula is getting bigger if there are number of worksheets.

    Please help me in simplyfing the formula. Also is there anyway to put the formula on the column instead of row wise. I can use a single formula on the column instead on every row in Adminsheet.

    To be clear my requirement is to count the occurrence of a search strings listed in Adminsheet column A across all worksheets and display count in Adminsheet column B


    Attaching the excel.

    Thank you,
    Pratap
    Attached Files Attached Files

  2. #2
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: COUNTIF across all worksheets of the same workbook

    Using Name Manager create a list of your tabs and the use
    =SUMPRODUCT(COUNTIF(INDIRECT("'"&list&"'!A2:A40"),A2))
    Template%20with%20the%20Formula_test(1).xlsx
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  3. #3
    Registered User
    Join Date
    01-08-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: COUNTIF across all worksheets of the same workbook

    Thanks Robert for the reply. cant we make it simple without any lists. I want count across all the sheets I feel like we shouldnot bother about the sheet names and lists.

    Can we create a formula counts across all sheets? (My idea is to eliminate sheet names completely so that same formula can be used across other simliar excels with minimal changes)

    Thanks

  4. #4
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: COUNTIF across all worksheets of the same workbook

    Quote Originally Posted by preythap View Post
    Thanks Robert for the reply. cant we make it simple without any lists. I want count across all the sheets I feel like we shouldnot bother about the sheet names and lists.

    Can we create a formula counts across all sheets? (My idea is to eliminate sheet names completely so that same formula can be used across other simliar excels with minimal changes)

    Thanks
    No we can not(not I know about).
    Sheets have names and Excel must know which one to use.
    If you SUM accorss you do not need 3D references but for any IF statment you have to have.

  5. #5
    Registered User
    Join Date
    01-08-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: COUNTIF across all worksheets of the same workbook

    Thanks again.

    can you help how to create this

    "Using Name Manager create a list of your tabs"

  6. #6
    Forum Contributor
    Join Date
    09-02-2013
    Location
    Netherlands
    MS-Off Ver
    Office 365 (2013)
    Posts
    268

    Re: COUNTIF across all worksheets of the same workbook

    You can also use a macro for this:

    Sub Rectangle1_Click()
     Dim iSheet As Integer
      On Error Resume Next
      Worksheets("Adminsheet").Range("B2:E2").Value = 0
      For i = ThisWorkbook.Sheets.Count To 2 Step -1
       Worksheets("Adminsheet").Range("B2").Value = Worksheets("Adminsheet").Range("B2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "Manager")
       Worksheets("Adminsheet").Range("C2").Value = Worksheets("Adminsheet").Range("C2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "Clerk")
       Worksheets("Adminsheet").Range("D2").Value = Worksheets("Adminsheet").Range("D2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "Programmer")
       Worksheets("Adminsheet").Range("E2").Value = Worksheets("Adminsheet").Range("E2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "HR")
      Next i
    End Sub

  7. #7
    Registered User
    Join Date
    01-08-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: COUNTIF across all worksheets of the same workbook

    Thankyou Evolta

    But how can i use this macro. Ive never used macro before

  8. #8
    Forum Contributor
    Join Date
    09-02-2013
    Location
    Netherlands
    MS-Off Ver
    Office 365 (2013)
    Posts
    268

    Re: COUNTIF across all worksheets of the same workbook

    Well I am kinda new with these things too.

    I usually make a button (insert/shapes) (since you need to activate the macro with something and I prefer buttons for this)
    Right click it: assign macro
    In that window press new

    past this:
     Dim iSheet As Integer
      On Error Resume Next
      Worksheets("Adminsheet").Range("B2:E2").Value = 0
      For i = ThisWorkbook.Sheets.Count To 2 Step -1
       Worksheets("Adminsheet").Range("B2").Value = Worksheets("Adminsheet").Range("B2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "Manager")
       Worksheets("Adminsheet").Range("C2").Value = Worksheets("Adminsheet").Range("C2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "Clerk")
       Worksheets("Adminsheet").Range("D2").Value = Worksheets("Adminsheet").Range("D2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "Programmer")
       Worksheets("Adminsheet").Range("E2").Value = Worksheets("Adminsheet").Range("E2").Value + WorksheetFunction.CountIf(Worksheets(i).Range("A:A"), "HR")
      Next i
    in between your sub and end sub part. (you can change the name of the sub to something more suitable )

    now just press the button to update it.

  9. #9
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: COUNTIF across all worksheets of the same workbook

    You need names of your sheets in one column(see example attadched in prevous post)
    Then in Formulas tab go to Named Manger-->New, Give a Name to your list and in Refers to higlight the names in column,Click ok/

+ 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. Worksheets from source to replace worksheets in the destination workbook when closed
    By anushatamby in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2013, 03:52 PM
  2. Copy/Paste Range of Data from Multiple Workbooks/Worksheets to Master Workbook/Worksheets
    By NumberCruncher311 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2013, 08:21 PM
  3. Copying Data from WorkSheets and Pasting them to a different Worksheets/Workbook
    By JRayhan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2013, 11:22 AM
  4. [SOLVED] Copying Worksheets from Multiple Workbooks to a Single Workbook, Separate Worksheets
    By DHartwig35805 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-27-2012, 11:38 AM
  5. Copying Worksheets from Multiple Workbooks to a Single Workbook, Separate Worksheets
    By Abhi_1977 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-27-2012, 11:32 AM

Tags for this Thread

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