Changing a Sumifs to a Sumproduct

Joshua Kao

New Member
Joined
Feb 14, 2021
Messages
16
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi, could someone please help me convert the sumifs formula in VBA, to a sumproducts please? Thank you.

ActiveCell.FormulaR1C1 = _
"=SUMIFS('Closing Stock.xlsx'!C3,'Closing Stock.xlsx'!C1,RC[-4])"
 
Ok, how about
VBA Code:
   Dim Pth As String
   Pth = Environ("userprofile")
   
   irow = Cells(Rows.Count, 1).End(xlUp).Row
   Range("E2:E" & irow).FormulaR1C1 = _
        "=SUMPRODUCT(('" & Pth & "\Desktop\PHMG\Stock Take\PS\[Closing Stock.xlsx]closing stock-PS'!R2C3:R1000C3)*('" & Pth & "\Desktop\PHMG\Stock Take\PS\[Closing Stock.xlsx]closing stock-PS'!R2c1:R1000C1=rc[-4]))"
    Range("F2:F" & irow).FormulaR1C1 = _
        "=SUMIFS(Master!C[-3],Master!C[-5],ComparisonM2K!RC[-5],Master!C[-2],ComparisonM2K!RC[-3])"
    Range("G2:G" & irow).FormulaR1C1 = "=(RC[-2]/RC[-1])*100-100"
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
If you select a cell with the formula in it & look at the formula bar, is the formula correct?
 
Upvote 0
oh nvm i forgot to change it from R2 to R3, the data starts from row 3 in the closing stock.
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,936
Messages
6,175,507
Members
452,650
Latest member
Tinfish

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top