Results 1 to 10 of 10

Thread: SUMPRODUCT returning FALSE

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,805
    Location
    I'm not sure why you are using SUMPRODUCT rather than SUMIF, but you could use:
    Sub SumCharges()
    Dim ws As Worksheet
    Dim LastRow As Long
    Dim ws1 As Worksheet
    Dim LastRow1 As Long
    Dim tAmount As Range
    Dim R As Long   'Used for Rows
    Dim sFormula As String
    Set ws = ThisWorkbook.Worksheets("Vehicle Listing")
    LastRow = ws.Range("A65536").End(xlUp).Row
    Set ws1 = ThisWorkbook.Worksheets("Event Repair - OK")
    LastRow1 = ws1.Range("A65536").End(xlUp).Row
    Set tAmount = ws.Range("P2:P" & LastRow)
    For R = 2 To LastRow   'Used for populating Rows
        If Cells(R, 1).Value <> "" Then
            sFormula = "sumproduct((A2:A" & LastRow & "=A2)*P2:P" & LastRow & ")"
            Cells(R, 4).Value = ws.Evaluate(sFormula)
        End If
    Next R
    End Sub
    Last edited by Aussiebear; 04-27-2023 at 12:08 PM. Reason: Reduced whitespace
    Be as you wish to seem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •