+ Reply to Thread
Results 1 to 7 of 7

DSUM database field across multiple ranges

  1. #1
    Registered User
    Join Date
    06-14-2006
    Posts
    13

    DSUM database field across multiple ranges

    Hey everyone,

    I've been stuck on this problem for a while today. I'm trying to use DSUM to give me totals in a database. The problem seems to be that the DSUM function needs to have the database columns in one continuous block; that is, you cant compose a database from different ranges. Is this true?

    To explain, I've attached an example.

    What I want to do is check the "Type" column for type a and add all of the values found to give a total. Is this possible or do the columns need to be next to each other? I keep getting #VALUE.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Type the word "Type" (without quotes) in, say, cell H1

    Then type the letter "a" (without quotes) directly below, in H2.

    Then use formula: =DSUM(B3:F31,"Values",H1:H2)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    06-14-2006
    Posts
    13
    Thanks for the quick reply

    Sorry I should've stated that I knew about the criteria layout part (Column heading and then criteria). I can get it working fine if I select the database as one block, but if for example I want just the two columns to be the database, I hold select the first range, hold control and select the second. This results in a #VALUE in the database field. The reason I'm trying to do it this way is that the columns in between contain weekly data. I want to look at one week at a time for each dsum that I do, i.e. the column would move to the right for each week (so the 'other data' column would be checked next).

    Does that make sense?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I'm not sure that it does make sense...

    Perhaps Sumif() will work for what you want.... the defined ranges are only the Criteria Range and the Sum Range....

    e.g. =SUMIF(F4:F31,"a",B4:B31) gives same result as my previous DSUM() formula.

  5. #5
    Registered User
    Join Date
    06-14-2006
    Posts
    13
    Well I mean I would like the database to exclude the in-between columns as they would give false results.

    So I want the 'database' selection to span two seperate ranges as i need seperate calculations for each week.

    A new example is attached
    Attached Files Attached Files

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I still think, then, that Sumif() will do the trick...

    For example, enter this formula in H4: =SUMIF($F$4:$F$31,"a",B4:B31) and then copy it down the column and across the other columns...

    You will note that the formula in I4 will be =SUMIF($F$4:$F$31,"a",C4:C31) and in J4 it will be =SUMIF($F$4:$F$31,"a",D4:D31)..

    so it sums only the column defined by the last range and always looks at column F for the "a".

  7. #7
    Registered User
    Join Date
    06-14-2006
    Posts
    13
    With a bit of tweaking that last solution worked perfectly. All I had to do was copy down and then strip out the $ signs and copy across. It's a perfect solution except now it takes forever to calculate as each formula checks 22,000 lines

    Oh well! Thanks a lot for solving my problem!

+ 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