+ Reply to Thread
Results 1 to 3 of 3

Is this a bug in WorksheetFunction.Dsum ?

  1. #1
    Registered User
    Join Date
    03-09-2013
    Location
    Ottawa,Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question Is this a bug in WorksheetFunction.Dsum ?

    I have found that the WorksheetFunction.DSum fails to work when the criteria block contains a condition on a date field.

    I have created a testcase using a toy data set of 10 rows and 5 fields. I display 2 versions of the criteria block, one filled in from the keyboard, the other generated by my macro. Results are displayed for WorksheetFunction.DSum and excel's DSUM , both functions are run with each version of the criteria block. My findings are ;
    • DSUM always works
    • DSum works if date fields are not used in criteria
    • DSum works if date field criteria is used and date has mm=dd
    • DSum does not work with a criteria on a general date value

    This obviously points to a problem interpreting the date format. I have tried many different ways to set the date value in my macro e.g #mm/dd/yy#,As Date, CDate(). In all cases, the results remain the same and the macro generated criteria block looks identical to the keyboard entered one.

    I will gladly post my test code (macro or spreadsheet) if it will be helpful. I would appreciate hearing from anyone who has experienced the same problem or who has a solution on how to handle date fields properly in a WorksheetFunction.DSum criteria block
    Last edited by jdwalsh; 03-13-2013 at 04:36 PM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Is this a bug in WorksheetFunction.Dsum ?

    It will be easy to understand if you show something in excel


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    03-09-2013
    Location
    Ottawa,Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Is this a bug in WorksheetFunction.Dsum ?

    I solved my problem with WorkFunction.DSum by carefully matching the format of a date field with the target database using the excel Text function.

    The problem was obfuscated by the fact that the excel DSUM function seemed to work on examples of criteria blocks where DSum failed. And of course DSum did work on some examples.

    I developed the test harness test_dsum to methodically explore some simplified test data. The ability to organize and record results soon led to the solution.

    The description from test_dsum documents the testing ;

    Please Login or Register  to view this content.
    I am attaching the test_dsum source code because I think it does a good job of managing simple testing, and it could be adapted to other test problems
    Attached Files Attached Files

+ 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