+ Reply to Thread
Results 1 to 4 of 4

VBA SumIf Result "TRUE" instead of a number

  1. #1
    Registered User
    Join Date
    11-22-2009
    Location
    Portland, OR, USA
    MS-Off Ver
    Excel 2007
    Posts
    43

    Question VBA SumIf Result "TRUE" instead of a number

    Hi guys,

    (Hopefully) quick question for you. I'm trying to use SumIf and it's been giving me a heck of a time all afternoon. I've tried using the worksheetfunction.sumif route and couldn't seem to get the syntax correct. I'd prefer the worksheetfunction route, as I don't need the formula stored, but it would be great to have both of these pieces of code for reference online - I scoured Google, and the examples I found were pretty weak.

    I've recorded the macro (hence the R1C1 references in the second example) and had it work perfectly, but when I replaced row references with my variables, it went back to displaying "TRUE." I'm including all the code here.

    Variables:
    expr = 3 to 38 (For loop)
    startrow = the starting row for the reference data
    endrow = the ending row for the reference data
    thresh = minimum threshold (a number)

    Syntax error here:

    Please Login or Register  to view this content.
    Returns "TRUE" instead of the sum I'm looking for:

    Please Login or Register  to view this content.
    Recorded macro that works:

    Please Login or Register  to view this content.
    Thanks for all your help! Love the forum... It's been a great resource and I hope to one day be on the other end of the questions when I get a little better at this. :-/
    Last edited by tbone90s; 12-07-2009 at 10:10 PM. Reason: solved

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: VBA SumIf Result "TRUE" instead of a number

    I believe the first code was just entered wrong,

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-22-2009
    Location
    Portland, OR, USA
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: VBA SumIf Result "TRUE" instead of a number

    Right on, Dave! Your code worked like a champ! You're the man!

    Thanks!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA SumIf Result "TRUE" instead of 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
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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