+ Reply to Thread
Results 1 to 3 of 3

VBA Function Formula Using Sum and If

  1. #1
    Registered User
    Join Date
    10-27-2009
    Location
    Wilmington, DE
    MS-Off Ver
    Excel 2007
    Posts
    2

    VBA Function Formula Using Sum and If

    I am using Excel 2007 on Windows XP. I have the following formula that I would like to move from the worksheet into VBA. I am having an issue with the “IF” statement within VBA throwing a compile error for “Expected: expression”. I am assuming it does not like the “IF” statement within the formula. I also provided a sample of the code that I was able to get working with a SUMIF statement but with only one condition. Any help would be appreciated. Thank you.

    Please Login or Register  to view this content.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please Login or Register  to view this content.
    Last edited by phooey123; 10-27-2009 at 01:41 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA Function Formula Using Sum and If

    Any particular reason you're not using the native SUMIFS function ?
    (new to XL2007)

    Your present formula would need to be an Array and the SUMIFS function will be far more efficient esp. if used over entire column references.

  3. #3
    Registered User
    Join Date
    10-27-2009
    Location
    Wilmington, DE
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA Function Formula Using Sum and If

    I used DonkyOte's suggestions which included using the SUMIFS and also read through the the Recommended Reading for Sumproduct which was an excelent source. Here is the solution that was used that worked perfectly.

    Please Login or Register  to view this content.

+ 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