+ Reply to Thread
Results 1 to 3 of 3

Tidying up a formula

  1. #1
    Registered User
    Join Date
    05-19-2004
    Posts
    26

    Tidying up a formula

    =SUM(COUNTIF(Wk1!$B$8:$F$11,A4),COUNTIF(Wk2!$B$8:$F$11,A4),COUNTIF(Wk3!$B$8:$F$11,A4),COUNTIF(Wk4!$B$8:$F$11,A4),COUNTIF(Wk5!$B$8:$F$11,A4))

    As you can see, I want to see how many times the contents of A4 appear in a group of fields on a range of worksheets. Is there a way to shorten this formula as when it is finished i need wk6 wk7 wk8 etc etc through to wk30.

    The formula is on the first work sheet, and there will be 30 subsequent worksheets so if it helps, i need that range of cells checking on every other worksheet.

    Thanks in advance.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Tidying up a formula

    There are a couple of approaches to this, but there is not one trivial solution.

    One approach is to put the COUNTIF formula on every sheet (let's say in G1), then use this

    =SUM(Wk1:Wk30!$G$1)but the initial setup would be tedious. This method of referencing a range of worksheets works with SUM but unfortunately not with COUNTIF.
    Another option is to write a user-defined function in VBA. I might be able to suggest something if you're interested in going that route.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

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

    Re: Tidying up a formula

    you could put the same formula eg COUNTIF($B$8:$F$11,A4) in all cells g1 at once by selecting all sheets and typing it in g1 of first sheet it will do all the others as well then use =SUM(Wk1:Wk30!$G$1)
    "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

+ 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