+ Reply to Thread
Results 1 to 8 of 8

Best way to count a value across a numerous columns

  1. #1
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Best way to count a value across a numerous columns

    I have a sheet with a list of names split into 8 columns. Inbetween each of these is a further 3 columns containing other pieces of numerical data. I am currently counting how many times a certain name occurs in all the columns by using COUNTIF(F1,AJ100,"name"). This works but it is counting across the entire field, eg 32 columns. I could do COUNTIF(F1,F100,"name")+COUNTIF(K1,K100)+ etc etc, but is there a more elegant way?

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Best way to count a value across a numerous columns

    Maybe sumproduct.

    =SUMPRODUCT(--(A1:Z99="name"))

    Adjust the range to suit.

    Or just use =COUNTIF(A1:Z99,"name")

    Unless the columns that you're excluding might contain the name that you want to count, it will make no difference having them in the formula.

    edit:-

    I misread your question, why are you looking for a different way? If it works why try to fix something that isn't broken?
    Last edited by jason.b75; 04-30-2016 at 06:50 AM.

  3. #3
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Best way to count a value across a numerous columns

    Yes it does work I was just thinking of the calculation overhead. That range will grow and grow, and I am counting more and more names in the field. Counting how many times a name appears in a few columns, across a field of 4 x 4 cells is one thing but what about when I am counting 20+ names across a field which could be 100 cells wide by a 1000 deep?

    It is unnecessary for the code to count 75% of the field, because the names only appear in one out of four columns, but that's what the code is currently doing.

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Best way to count a value across a numerous columns

    if you upload a sample excel file with expected result you will get the better result
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Registered User
    Join Date
    05-03-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: Best way to count a value across a numerous columns

    I guess what Im asking for is a shorthand way of writing COUNTIF(F1,F100,"name")+COUNTIF(K1,K100)+COUNTIF(O1,O100)etc etc, something like COUNTIF(F1,F100,K1,K100,O1,O100,"name")... eg count single columns across a wide date field without actually having to type in up to 20 COUNTIF statements or count multiple columns that dont need counting Is there a way of doing this?

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Best way to count a value across a numerous columns

    Please Login or Register  to view this content.
    maybe there are other (better) solutions.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Best way to count a value across a numerous columns

    Quote Originally Posted by AndyGW View Post
    It is unnecessary for the code to count 75% of the field, because the names only appear in one out of four columns, but that's what the code is currently doing.
    Unnecessary, but more efficient, even with 100 columns by 1000 rows, which to put in perspective, is less than 10% of a whole column, yet you would probably use =COUNTIF(A:A,"name") without a second thought.

    20+ names to count is negligible for a range that size, viewing this thread is probably using more processing effort than those countif formulae will waste.

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

    Re: Best way to count a value across a numerous columns

    As long as "name" doesn't appear in the columns between the target columns then:

    =COUNTIF(F1:AJ100,"name")

    Is the best option.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ 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] Count If Numerous Conditions are TRUE
    By gshafiq in forum Excel General
    Replies: 2
    Last Post: 07-09-2015, 01:46 PM
  2. [SOLVED] Macro to move data from (1) column to numerous columns
    By SeanEboy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-10-2015, 05:25 PM
  3. I have numerous columns with a paired alphabets need a count on A
    By SAMEEP in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2012, 04:53 PM
  4. [SOLVED] Coping certian columns from numerous sheets in workbook to a new sheet
    By TERRI LEE in forum Excel Programming / VBA / Macros
    Replies: 73
    Last Post: 09-19-2012, 05:36 AM
  5. [SOLVED] How to move numerous sets of data from columns to rows within a table?
    By Rob8489 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2012, 05:58 AM
  6. [SOLVED] Count Numerous Matches Only Once
    By Paul Black in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2005, 08:05 AM
  7. Need to sum up numerous columns in different worksheet into 1
    By devil135 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-26-2005, 05:15 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