+ Reply to Thread
Results 1 to 3 of 3

Turn Sumproduct Calculation Into vba

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro Plus 2021
    Posts
    424

    Turn Sumproduct Calculation Into vba

    Hi,

    I have this calcualtion in G4 on a worksheet. Is there a way to get a macro to put this calculation into G4 and copy it to bottom of the data the range of which moves up and down on a monthly basis?

    =SUMPRODUCT((Download!I4:I54862="CUSTOMER1")*(Download!H4:H54862=CUSTOMER1!H4)*(Download!G4:G54862))

  2. #2
    Valued Forum Contributor
    Join Date
    11-15-2007
    Location
    England
    MS-Off Ver
    Office Pro Plus 2021
    Posts
    424

    Re: Turn Sumproduct Calculation Into vba

    I have come up with this but it doesn't get around the range problem. i.e. 54858 needs replacing with siommething like lrow.

        ActiveCell.Offset(3, 6).Range("A1").Select
        ActiveCell.FormulaR1C1 = _
            "=SUMPRODUCT((Download!RC[2]:R[54858]C[2]=""CUSTOMER1"")*(Download!RC[1]:R[54858]C[1]=CUSTOMER1!RC[1])*(Download!RC:R[54858]C))"
        ActiveCell.Offset(1, 0).Range("A1").Select

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Turn Sumproduct Calculation Into vba

    Try this

    Sub t()
    Dim lr As Long
     lr = Worksheets("Download").Cells(Rows.Count, "i").End(xlUp).Row
     Range("G4").Resize(Cells(Rows.Count, "h").End(xlUp).Row) _
        .Value = "=SUMPRODUCT((Download!$I$4:$I$" & lr & "=""CUSTOMER1"")*(Download!$H$4:$H" & lr & "=CUSTOMER1!H4)*(Download!$G$4:$G$" & lr & "))"
    
    End Sub
    Last edited by mike7952; 09-20-2012 at 06:12 AM.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

+ 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