+ Reply to Thread
Results 1 to 4 of 4

Sum counts in a column based on string contents in another column

  1. #1
    Registered User
    Join Date
    08-25-2019
    Location
    Alsike
    MS-Off Ver
    7/8
    Posts
    2

    Sum counts in a column based on string contents in another column

    Hi forum,

    I need to sum the counts of a very long column based on an associated string in another column. Like this:

    the1first,category 3
    the2second,category 5
    this2first,category 124
    the1third,category 13
    that1first,category 9
    the2second,category 10
    the3third,category 7

    What I need is something like this

    first 136
    second 15
    third 20

    I could, of course, sort these columns, but this is a bad option with many rows. Any smart suggestions would be greatly appreciated.

    Best, Christoffer

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,725

    Re: Sum counts in a column based on string contents in another column

    You could use SUMIFS with a wildcard character. If you have first, second, third etc. listed down column F with your date in columns A to C, then you could use this in G1:

    =SUMIFS(C:C,A:A,"*"&F1&"*")

    then copy down.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    08-25-2019
    Location
    Alsike
    MS-Off Ver
    7/8
    Posts
    2

    Re: Sum counts in a column based on string contents in another column

    Thanks for your reply, but I unfortunately cannot really make sense of it and it does not work (likely my own fault/incompetence in explaining). If I have

    the1first,category

    in F1, then your formula gives me NAME?

    I have several columns with numbers, and I need a separate count for first, second and third etc. for each. Here is a screenshot of a fraction of my actual table - perhaps that is better. Attachment 638895

    I would like a total count of each category in A-C 20-22. Hope this was clearer. Best, Christoffer

    the1firstcategory 3
    the2secondcategory 5
    this2firstcategory 124
    the1thirdcategory 13
    that1firstcategory 9
    the2secondcategory 10
    the3thirdcategory 7

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,725

    Re: Sum counts in a column based on string contents in another column

    I cannot see your attachment - it comes up with Invalid Attachment. A picture is not much use to us anyway - it is better to attach a sample Excel workbook, and then we can try different things out.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Don't try to use the Paperclip icon, as it doesn't work on this forum.

    Your profile states that you are using Office version 7/8, but I don't know what that means. If it is Excel 2003 or earlier, then SUMIFS did not exist in those versions - you will need to use SUMIF instead, though the syntax is a bit different:

    =SUMIF(A:A,"*"&F1&"*",C:C)

    This assumes that the numbers you want to add are in column C.

    I'm not sure where Alsike is, but you may need to use semicolons ( ; ) instead of commas ( , ) in the formula, depending on your regional settings.

    Hope this helps.

    Pete

+ 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] Code that Counts number of time string occurs in a column
    By adebayo_seun in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-05-2014, 11:40 AM
  2. Replies: 2
    Last Post: 01-08-2014, 03:50 PM
  3. Adding column B based on part of column A contents
    By Mornemoz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-24-2013, 03:22 AM
  4. Formula/macro to edit cells in one column based on contents of a cell in another column
    By robbyvegas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-25-2012, 06:10 AM
  5. [SOLVED] Search 1st Column for Date older than 5 days based on 2nd column contents
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-31-2012, 10:49 PM
  6. Counting cells in offset column based on contents of another column.
    By Big Chris in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-10-2008, 09:25 AM
  7. [SOLVED] move contents of column C based on criteria related to column A
    By Debra in forum Excel General
    Replies: 2
    Last Post: 12-27-2005, 06:30 PM

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