+ Reply to Thread
Results 1 to 4 of 4

To sum a table if a cell contains numbers

  1. #1
    Registered User
    Join Date
    06-11-2009
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    2

    To sum a table if a cell contains numbers

    Hi everyone, great forum!
    Here´s my question:

    I have a table called "table". Two columns in the table, named "date" and "amount".

    In the "date" column, I have a date that is formatted like this YYYYMMDD

    My table looks like this:
    Please Login or Register  to view this content.
    I am trying to write a formula that sums the correspondent cells in column "amount", when "date" contains "200905" (in the table example above, the sum I´m after would be 300).

    These are the formulas I´m not getting to work:
    Please Login or Register  to view this content.
    I´ve also tried with wild cards, such as:
    Please Login or Register  to view this content.
    I´ve also tried to change the format of the date-column to text and numbers, with no improvement. Any suggestions??
    Thanks!

    *edit*
    If I have text in the "date" column instead of numbers, the first formula above works. For instance, if the table is:
    Please Login or Register  to view this content.
    Then the formula
    Please Login or Register  to view this content.
    would return 300
    Last edited by Exkast; 06-11-2009 at 04:57 PM.

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

    Re: To sum a table if a cell contains numbers

    =sumproduct((month($a$1:$a$100)=5)*(year($a$1:$a$100)=2009)*$b$1:$b$100)
    "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

  3. #3
    Registered User
    Join Date
    06-11-2009
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: To sum a table if a cell contains numbers

    This works if column "date" is formatted as date, thanks!

    Could I get it to work if the column "date" is formatted as "general" (no specific format)?

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

    Re: To sum a table if a cell contains numbers

    yep try
    =SUMPRODUCT(--(LEFT(A1:A100,4)="2009"),--(MID($A$1:$A$100,5,2)="05"),$B$1:$B$100)

+ 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