+ Reply to Thread
Results 1 to 9 of 9

Want to streamline a COUNTIF formula

  1. #1
    Registered User
    Join Date
    07-12-2014
    Location
    USA
    MS-Off Ver
    2003
    Posts
    37

    Want to streamline a COUNTIF formula

    I'm doing a COUNTIF for various keywords in multiple non-adjacent columns. So right now, this is what I have:

    =COUNTIF(Sheet2!A:A,"Blank")+COUNTIF(Sheet2!F:F,"Blank")+COUNTIF(Sheet2!K:K,"Blank")+COUNTIF(Sheet2!P:P,"Blank")+COUNTIF(Sheet2!U:U,"Blank")+COUNTIF(Sheet2!Z:Z,"Blank")+COUNTIF(Sheet2!AE:AE,"Blank")

    The problem is that I'm be gonna be doing the formula almost a hundred different times, with the "Blank" representing a different keyword in each one. Is there some way to streamline this so I only have to change the blank once for each one?

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Want to streamline a COUNTIF formula

    If I understand what you're asking...

    Use a cell to hold "blank" then just refer to that cell.

    That way all you have to do is change the cell entry and not the formula.

    A1 = blank

    =COUNTIF(Sheet2!A:A,A1)+COUNTIF(Sheet2!F:F,A1)+COUNTIF(Sheet2!K:K,A1)+COUNTIF(Sheet2!P:P,A1)+COUNTIF(Sheet2!U:U,A1)+COUNTIF(Sheet2!Z:Z,A1)+COUNTIF(Sheet2!AE:AE,A1)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Want to streamline a COUNTIF formula

    Hi,

    I don't understand.

    When you say the formula will be repeated almost a 100 times, what is 'the formula'. Is that the whole of the series of COUNTIF() functions or is each COUNTIF() a 'formula'.

    You say you want to replace the "Blanks' wit a different keyword but then say you only want to change the blanks once.

    It would help if you uploaded a workbook with some examples and manually add the results you expect to see.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    07-12-2014
    Location
    USA
    MS-Off Ver
    2003
    Posts
    37

    Re: Want to streamline a COUNTIF formula

    I think I can try to make this more clear without uploading a whole workbook. There will be lists of names that appear in columns A, F, K, P, U, Z, and AE. So, let's say I have the names Tom, Rick, and Harry. I can post the following formulas in separate cells...

    =COUNTIF(Sheet2!A:A,"Tom")+COUNTIF(Sheet2!F:F,"Tom")+COUNTIF(Sheet2!K:K,"Tom")+COUNTIF(Sheet2!P:P,"Tom")+COUNTIF(Sheet2!U:U,"Tom")+COUNTIF(Sheet2!Z:Z,"Tom")+COUNTIF(Sheet2!AE:AE,"Tom")

    =COUNTIF(Sheet2!A:A,"Rick")+COUNTIF(Sheet2!F:F,"Rick")+COUNTIF(Sheet2!K:K,"Rick")+COUNTIF(Sheet2!P:P,"Rick")+COUNTIF(Sheet2!U:U,"Rick")+COUNTIF(Sheet2!Z:Z,"Rick")+COUNTIF(Sheet2!AE:AE,"Rick")

    =COUNTIF(Sheet2!A:A,"Harry")+COUNTIF(Sheet2!F:F,"Harry")+COUNTIF(Sheet2!K:K,"Harry")+COUNTIF(Sheet2!P:P,"Harry")+COUNTIF(Sheet2!U:U,"Harry")+COUNTIF(Sheet2!Z:Z,"Harry")+COUNTIF(Sheet2!AE:AE,"Harry")

    ...And that will get me the counts of how many times those three names appeared in the relevant columns. But if I have a hundred different names that I want to count, then I have to change the name in that formula a hundred different times, and I'd like to find a way to make that process a little less tedious. Does that make more sense?

  5. #5
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Want to streamline a COUNTIF formula

    Hi -

    Tony Valko is spot on with using a cell to easily change your search criteria rather than hard coding it into your formula. You could also use SUMPRODUCT and get rid of all the COUNTIF's such as:

    =SUMPRODUCT(--(Sheet2!A:A,$A$1)+--(Sheet2!F:F,$A$1)+--(Sheet2!K:K,$A$1)+--(Sheet2!P:P,$A$1)+--(Sheet2!U:U,$A$1)+--(Sheet2!Z:Z,$A$1)+--(Sheet2!AE:AE,$A$1))
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Want to streamline a COUNTIF formula

    Still not clear (to me).

    Does that mean you want to do something like this:

    =COUNTIF(Sheet2!A:A,100 names)+COUNTIF(Sheet2!F:F,100 names)+ etc., etc.

  7. #7
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Want to streamline a COUNTIF formula

    Hi -

    Just saw your last post. I still think Tony Valko has the best approach. Just use Row 1 to put your list of names (A1, B1, C1 are Tom, Rick Harry, etc.)
    Put your formula in A2 and just make the address reference relative (e.g., no $A$1) and copy to the right. Easy!

  8. #8
    Registered User
    Join Date
    07-12-2014
    Location
    USA
    MS-Off Ver
    2003
    Posts
    37

    Re: Want to streamline a COUNTIF formula

    Quote Originally Posted by loginjmor View Post
    Hi -

    Just saw your last post. I still think Tony Valko has the best approach. Just use Row 1 to put your list of names (A1, B1, C1 are Tom, Rick Harry, etc.)
    Put your formula in A2 and just make the address reference relative (e.g., no $A$1) and copy to the right. Easy!
    I didn't understand what he was saying at first, but it's clicked for me now, and that does make a lot more sense. But, can you tell me how SUMPRODUCT as better than COUNTIF? The formula doesn't look any more streamlined to me.

  9. #9
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Want to streamline a COUNTIF formula

    Hi -

    SUMPRODUCT isn't better than COUNTIF. You just don't have to repeat the COUNTIF text over and over again. Just a little easier to read. At this point since you have your formula set up, I would just go with it.

+ 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. [SOLVED] Streamline InputBox
    By lloydgodin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-19-2012, 04:13 PM
  2. Excel 2007 : How do I streamline this?
    By ChrisLehrich in forum Excel General
    Replies: 5
    Last Post: 10-16-2011, 01:17 PM
  3. Help to streamline my code.
    By gpwaters in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-21-2011, 02:55 PM
  4. Streamline .csv export
    By Kingprawn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-29-2010, 05:58 PM
  5. [SOLVED] Streamline macro
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-20-2010, 09:06 AM
  6. Streamline Dates
    By tek9step in forum Excel General
    Replies: 2
    Last Post: 07-21-2009, 11:44 AM
  7. How to streamline this Formula?
    By Kuda in forum Excel General
    Replies: 1
    Last Post: 02-07-2006, 11:10 AM
  8. [SOLVED] streamline SUMPRODUCT
    By gpie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-23-2005, 02:05 PM

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