+ Reply to Thread
Results 1 to 4 of 4

Can I set the criteria in a sumif statement as a cell reference?

  1. #1
    Duncan
    Guest

    Can I set the criteria in a sumif statement as a cell reference?

    I am trying to use the sumif statement in excel and want to set the criteria
    to a "less than" date. The only way I can get the formula to work is by
    hardcoding the date into the sumif statement i.e
    =sumif(A1:II1,"<31-OCT-05",A2:II2). However I want to copy this formula using
    a number of different dates and do not want to individually hard code the
    date. I want to replace the hard coded date with a cell reference that
    contains the date. When I do this I get the microsoft excel pop up box
    telling me there is an error in my formula.

  2. #2
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    I used this formula

    =SUMIF(A1:A9,D2,B1:B9)

    Where Cell D2 was formatted as a date and I input "<2/27/1991" into that cell just as it appears without the quotes and the sum worked.
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

  3. #3
    MarkN
    Guest

    RE: Can I set the criteria in a sumif statement as a cell reference?

    Hi Duncan,

    How about =SUMPRODUCT(--(A2:A4>F1),B2:B4) where A2:A4 contain the dates, F1
    contains the referenced date cell and B2:B4 the values.
    --
    Thanks,
    MarkN


    "Duncan" wrote:

    > I am trying to use the sumif statement in excel and want to set the criteria
    > to a "less than" date. The only way I can get the formula to work is by
    > hardcoding the date into the sumif statement i.e
    > =sumif(A1:II1,"<31-OCT-05",A2:II2). However I want to copy this formula using
    > a number of different dates and do not want to individually hard code the
    > date. I want to replace the hard coded date with a cell reference that
    > contains the date. When I do this I get the microsoft excel pop up box
    > telling me there is an error in my formula.


  4. #4
    JMB
    Guest

    RE: Can I set the criteria in a sumif statement as a cell reference?

    Where B1 contains the date:
    =sumif(A1:II1,"<"&B1,A2:II2)


    "Duncan" wrote:

    > I am trying to use the sumif statement in excel and want to set the criteria
    > to a "less than" date. The only way I can get the formula to work is by
    > hardcoding the date into the sumif statement i.e
    > =sumif(A1:II1,"<31-OCT-05",A2:II2). However I want to copy this formula using
    > a number of different dates and do not want to individually hard code the
    > date. I want to replace the hard coded date with a cell reference that
    > contains the date. When I do this I get the microsoft excel pop up box
    > telling me there is an error in my formula.


+ 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