+ Reply to Thread
Results 1 to 10 of 10

Countif to find total sales

  1. #1
    Forum Contributor
    Join Date
    02-20-2007
    Location
    Alaska
    MS-Off Ver
    2003, 2007, 2010
    Posts
    105

    Countif to find total sales

    I have a column of names, and I want to be able to count all the instances of each name, as each instance represents a sale of a product.

    Countif(Sales!B:B,"Dave") works, counting all the instances of Dave.

    But if I have all the names in column A, and try to have column B give the results (from another WS), as in: =COUNTIF(Sales!B:B,'Best Customers'!A1), I get a "0" as the result. Yet XL help says countif can be used as =COUNTIF(A2:A5,A4). where A4 holds the value to search for.

    While we are exploring this, is there a good way to look in a column, get every different instance of the names, and output them into another column?

    TIA!

  2. #2
    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
    Hi,

    The fact that you get a zero means that the syntax of the formula is correct. Check the values of the names in column B of the Sales sheet. The chances are that you have some trailing or leading spaces. e.g. " Dave " rather than just "Dave".

    Use Data Filter Advanced Filter to copy values from one range to another range elsewhere.

    HTH

  3. #3
    Forum Contributor
    Join Date
    02-20-2007
    Location
    Alaska
    MS-Off Ver
    2003, 2007, 2010
    Posts
    105
    That's not it, as I have MANY names in column B, and they all return a 0. If I change the name in the forumla to "Dave", it finds them all. Using a cell reference to column A yields all zeroes.

    Not sure how you mean to use advanced filter to copy names... I am trying to look at a column (on the sales sheet, say 1000 names total), find all unique names (put them in a column on another sheet, say 200 unique names), then using the new column as a reference, count the number of times each name appears (how many sales each customer has).

  4. #4
    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
    Hi,

    It's probably best if you upload your workbook, or at least a representative sample of it so that we can see your problem in context.

    The Advanced Filter using the Unique option should it seems do exactly what you're looking to achieve. Have you checked out this functionality?

    Rgds

  5. #5
    Forum Contributor
    Join Date
    02-20-2007
    Location
    Alaska
    MS-Off Ver
    2003, 2007, 2010
    Posts
    105
    Ok, here's a snippet of what I am looking at, and what I would like it to do.

    I want to run down the Sales sheet, counting unique customers' sales. Easy to do (see RESULTS TAB), with COUNTIF(Sales!B:B,A1). But the first task is CREATING this list in the first place from the Sales tab, and placing it on the Customers tab (so that it looks like the Results tab).

    This allows me to calculate how many times a person is listed. But I'd like to take that one farther, and when a person is found on the Sales Tab, B:B, instead of just counting 1, I'd like to count the Amount & divide by $10.

    I also tried the Advanced Filter option (never noticed it before, new to 2007, and thanks for pointing it out to me!), but selecting Filter selects the range, selecting Advanced allows the unique button, but when I use B3:B25 as the criteria, it hides ALL entries. Perhaps I am not understanding how it works...

    Thanks for your assistance.
    Attached Files Attached Files
    Last edited by F6Hawk; 01-19-2009 at 11:12 PM.

  6. #6
    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
    Hi,

    To get a unique list of customers first name the range A2:D25 on the Sales Sheet 'Data'

    Copy the column label 'Customer' to A1 on the Customers tab and name A1 'Data_Out'

    Now with cursor in A1 from the menu pick Data, Advanced, in the List Range type the word 'Data', select the 'Copy to another location' option, in the copy to box type 'Data_Out' and tick the 'Unique records only' box and then OK.

    For your formula (in B1 on the Results sheet use a SUMIF() instead.
    e.g.

    Please Login or Register  to view this content.
    Rgds

  7. #7
    Forum Contributor
    Join Date
    02-20-2007
    Location
    Alaska
    MS-Off Ver
    2003, 2007, 2010
    Posts
    105
    Thanks, Richard. I decided to create a macro to automatically do the "look for unique customers & count their purchases, then sort them", and ran into a problem. Here's my code thus far:

    Please Login or Register  to view this content.
    This works great up to the part where I try to sort based on the number of purchases made, and the sort gives me garbage. Why is it not sorting correctly? Both column A & B are general in format.

  8. #8
    Forum Contributor
    Join Date
    02-20-2007
    Location
    Alaska
    MS-Off Ver
    2003, 2007, 2010
    Posts
    105
    B U M P it up, I think it may have been missed.

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    12-20-2008
    Location
    US
    MS-Off Ver
    Excel 2007, Student Version
    Posts
    33
    Here are some more possibilities with Excel 2007
    No formulas or code.
    All dynamically updated.
    Chart, colors gratis.
    http://www.mediafire.com/file/zkmyymrtmzm/SalesEx.xlsx

+ 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