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
Excel Formula:
   ActiveCell.FormulaR1C1 = "=SUMPRODUCT(('C:\MrExcel\[Closing Stock.xlsx]closing stock-PS'!C3)*('C:\MrExcel\[Closing Stock.xlsx]closing stock-PS'!c1=rc[-4]))"
You will need to change the file path in the formula to suit.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
hmm, does it need to be in that specific location? or if its in a different folder, would it prompt to select the file?
 
Upvote 0
You just need to change the path to where the workbook is located.
 
Upvote 0
When i run the macro, even with both workbooks open, im getting a #value error.
 
Upvote 0
Can you post the code you are using.
 
Upvote 0
This is the whole sumifs portion that im using it for

VBA Code:
                   irow = 2
    Do While Cells(irow, 1).Value <> ""
    Cells(irow, 5).Select
    ActiveCell.FormulaR1C1 = _
        "=SUMPRODUCT(('C:\Users\Joshua Kao\Desktop\PHMG\Stock Take\PS\[Closing Stock.xlsx]closing stock-PS'!C3)*('C:\Users\Joshua Kao\Desktop\PHMG\Stock Take\PS\[Closing Stock.xlsx]closing stock-PS'!c1=rc[-4]))"
          Cells(irow, 6).Select
    ActiveCell.FormulaR1C1 = _
        "=SUMIFS(Master!C[-3],Master!C[-5],ComparisonM2K!RC[-5],Master!C[-2],ComparisonM2K!RC[-3])"
            Cells(irow, 7).Select
    ActiveCell.FormulaR1C1 = "=(RC[-2]/RC[-1])*100-100"
         irow = irow + 1
         Loop[CODE=vba]
[/CODE]
 
Upvote 0
Do you have any text or formulae that return "" in col C?
 
Upvote 0
that part is saying that if C is filled to execute the below formulas, if its blank then it wont execute it.
 
Upvote 0
Apologies, I wasn't clear, I meant is there any text or formula that return "" on col C of the closing stock-PS sheet?
 
Upvote 0
oh, there is none, every row in the closing stock that has data is a numerical value in column C.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

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