+ Reply to Thread
Results 1 to 3 of 3

VBA - Strange behavior with Application.Evaluate and Sumproduct

  1. #1
    Registered User
    Join Date
    03-31-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Exclamation VBA - Strange behavior with Application.Evaluate and Sumproduct

    Hi All,

    My first post here.

    I have come across some unusual behavior in VBA with regards to Sumproduct when used in application.evaluate - I have posted some code below as an example:

    =IF(([Daily_New.xlsx]Output!$L$2+0)-[Daily_New.xlsx]Output!$I$2>0,"",SUMPRODUCT((ROUNDDOWN([Database_new.xlsx]UserData!$T$2:$T$22815,0)=([Daily_New.xlsx]Output!$L$2+0))*([Database_new.xlsx]UserData!$E$2:$E$22815>=16)*([Database_new.xlsx]UserData!$E$2:$E$22815<=25)))

    The strange behavior is that if I try to evaluate this with application.evaluate, it generates Error 2015, but if I paste it verbatim into the sheet, it calculates just fine.

    Additionally, if I remove any one of the 3 conditions, and then do application.evaluate, again it works fine.

    Is there some difference with the application.evaluate function in VBA that allows it to take only two Sumproduct conditions, despite the fact that it will work normally in the sheet?

    Thanks for any assistance!

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: VBA - Strange behavior with Application.Evaluate and Sumproduct

    I think it's because your formula string is over 255 characters, not because of the complexity or number of functions per se.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    03-31-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA - Strange behavior with Application.Evaluate and Sumproduct

    I just noticed that - thanks for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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