+ Reply to Thread
Results 1 to 6 of 6

VBA: using Evaluate with sumproduct function ( Date Comparison not working)

  1. #1
    Forum Contributor
    Join Date
    02-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    102

    VBA: using Evaluate with sumproduct function ( Date Comparison not working)

    Hello,

    I am relatively new to this forum. Please accept my apologies if i had missed out on any forum rules. Now..

    1. i have a vba code which uses evaluate with Sumproduct function and it is (rather...was!) working
    2. i tried to expand this by including a date comparison but it is not working
    3. Date is stored in a cell which is in turn stored in a variable and i used that variable in the function
    4. Xmonth and Xweek (mentined below in code ) are names defined. we can assume Xdate also as same.
    5. Val1 / Val2 is declared as variant and it has values from cell and val3 stores date.

    Relevant extract from the code
    val1=range("i3").value
    val2=range("i4").value
    val3=range("i5").value

    myval=evaluate("=sumproduct((xmonth=""" & val1 &""")*(xweek=""" & val2 &""")

    but..if i append this with the following code it doesn't work...i tried multiple options like clng,datevalue etc..it give #name,#value and error message at times.

    myval=evaluate("=sumproduct((xmonth=""" & val1 &""")*(xweek=""" & val2 &""")*(xdate=""" & val3 &""")

    can someone help me out on this..and please revert for any additional information which is required which can help me in getting a resolution. Thx.
    Last edited by vidyuthrajesh; 02-27-2012 at 11:54 AM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA: using Evaluate with sumproduct function ( Date Comparison not working)

    There are parenthesis missing
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Contributor
    Join Date
    02-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: VBA: using Evaluate with sumproduct function ( Date Comparison not working)

    my apologies...the vba code was in a different machine and it was typo error to have missed parenthesis... i have the same code ...but not giving desired result...if we do date compare do we have to do some conversion? ( using clng,datevalue etc..)
    Thx.

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA: using Evaluate with sumproduct function ( Date Comparison not working)

    If you want date (without times) use CLng and don't include quotes round the value:

    Please Login or Register  to view this content.
    Good luck.

  5. #5
    Forum Contributor
    Join Date
    02-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: VBA: using Evaluate with sumproduct function ( Date Comparison not working)

    resolved..thx a ton

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA: using Evaluate with sumproduct function ( Date Comparison not working)

    Please mark the thread solved then - see FAQ link at the top of the page for details.

+ 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