VBA SUMIFS Not working

  • I have prepared a below code which works like SUMIFS functions works. But the problem is my code is not pasting an answer when i run.

    I have attached a File which has 3 sheets and Sheet2 Col"C" has formula. the formula subtracting the Sheet1 Quantity from Sheet3 then paste its result in Sheet2 after matching Col"A", B and D.

    Any help will be appreciated.

    Or is there any better solution then please share.

    Files

    • Sheet1.xlsx

      (13.56 kB, downloaded 64 times, last: )
  • VBA code


  • Hello,


    Have you tried to turn on your macro recorder ... to input your formula ...?


    You would get your "VBA translation" right away ...:)


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Hello again,


    For example


    Code
    1. Sub mythu()
    2. Dim c As Range
    3. For Each c In Sheet2.Range("C2:C15")
    4. c = Evaluate("=SUMPRODUCT((Sheet1!$A$2:$A$15=Sheet2!A" & c.Row & ")*(Sheet1!$B$2:$B$15=Sheet2!B" & c.Row & ")*(Sheet1!$D$2:$D$15=Sheet2!D" & c.Row & ")*(Sheet1!$C$2:$C$15))-SUMPRODUCT((Sheet3!$A$2:$A$15=Sheet2!A" & c.Row & ")*(Sheet3!$B$2:$B$15=Sheet2!B" & c.Row & ")*(Sheet3!$D$2:$D$15=Sheet2!D" & c.Row & ")*(Sheet3!$C$2:$C$15))")
    5. Next c
    6. End Sub


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Thanks for your Thanks ...AND for the Like :thumbup:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)