+ Reply to Thread
Results 1 to 4 of 4

Sumproduct in vba (formula array)

  1. #1
    Registered User
    Join Date
    02-17-2008
    Posts
    51

    Sumproduct in vba (formula array)

    Hello everyone,

    I have a function that has a formula sumproduct and here it is:

    Set RSheet = Worksheets("Rawdata")
    Set RSheet = Worksheets("Rawdata")

    RSheet_lastRow = RSheet.Cells(Rows.Count, "A").End(xlUp).Row
    RSheet.Range("AJ2:AJ" & RSheet_lastRow).Formulaarray = "=SUMPRODUCT
    ((V2>=ProjectedStarts!$K$1:$K$45)*(V2<=ProjectedStarts!$L$1:$L$45),ProjectedStarts!$M$1:$M$45)"

    The problem is that when the formula is sent to each cell V2 (bolded) does not change to V3, V4, V5.

    Am I doing something wrong? Could you please find the error that I am making?

    Thanks,
    Last edited by Statsman; 05-12-2009 at 08:12 AM. Reason: Problem solved. Thanks everyone

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,960

    Re: Sumproduct in vba (formula array)

    Please insert you code between the code tags to facilitate reading/copying.
    Post all the code or, better yet, a workbook. We need to know how the variables are TYPED/DIM'ed
    Ben Van Johnson

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

    Re: Sumproduct in vba (formula array)

    Ditto ProtonLeah re: tags...

    re: prior to posting back be sure to check out .FormulaR1C1 in VBA Help ... you don't need to enter your Sumproduct formula as an Array given it isn't a CSE Array formula in this instance.

  4. #4
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Sumproduct in vba (formula array)

    I agree with Donkey, but here's one way of collecting the syntax.

    Write the formula in the cell. Then on the menu toolbar go to Tools > Options > General (tab) and check R1C1 reference style.

    Then return to your worksheet and copy the SUMPRODUCT formula and use that in your code instead. Should read something like:

    Please Login or Register  to view this content.
    Regards

    Jon (Excel 2003, 2007, 2010, 2013)

+ 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