+ Reply to Thread
Results 1 to 5 of 5

SUMing two IF Values

  1. #1
    Registered User
    Join Date
    07-29-2008
    Location
    Washington St
    Posts
    13

    SUMing two IF Values

    Here's what I want the formula to do for me:
    I'm in regional sales and need to track sales figures (column C) within a City (column A) within a specific date range (column B). See attached xls example file.
    I have tried nesting AND and SUM into an IF formula as well as an INDEX formula with no success.
    Any thoughts? Thanks!
    Attached Files Attached Files
    Last edited by HiDbLevel; 01-02-2009 at 06:08 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    =SUMPRODUCT((Sales!$A$2:$A$12='City Raw Data'!$A2)*(YEAR(Sales!$B$2:$B$12)=RIGHT(B$1,4)+0)*(Sales!$C$2:$C$12))
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    pinmaster
    Guest
    Hi,

    Try something like this in B2 of the "city raw data" sheet then drag across and down:

    =SUMPRODUCT((Sales!$A$2:$A$12=$A2)*(YEAR(Sales!$B$2:$B$12)=ABS(RIGHT(B$1,4))),Sales!$C$2:$C$12)
    HTH
    Jean-Guy

  4. #4
    Registered User
    Join Date
    07-29-2008
    Location
    Washington St
    Posts
    13
    SUMPRODUCT worked like a champ. Thanks! Although, I'm curious because I have no clue how it knows the year I'm looking for when the cell (B1) said "Sales 2008". I didn't know that excel could look for numbers within a text/num cell. Interesting.

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    The right function returns the last 4 characters e.g returns 2007 for text "Sales 2007" and by adding the zero it converts it to a number

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

    VBA Noon

+ 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