SUMIF criteria in row not columns

coop123

Board Regular
Joined
Dec 18, 2018
Messages
66
Office Version
  1. 365
Hi

I am sorry if this question has already been resolved but I cannot find a solution that meets my needs.

I have spread sheet where the criteria is in row 5 and sum range is also a row.

The problem is the number of columns containing the criteria will be different each time report is run.

1643293459658.png


In above example there are only 2 sets of data, next time there maybe 4 sets or just 1.

I need to be able to sum the data if there are 2 records or 4 or 1.

I hope I have explained suffeciently.

Thanks for any assistance you can give.

Coop123
 
Sorry not sure what I did there.

For a single cell:-
VBA Code:
    sht.Cells(firstRow, lastCol).FormulaR1C1 = _
        "= SUMIFS(RC3:RC" & lastCol - 1 & ",R" & hdgRow & "C3:R" & hdgRow & "C" & lastCol - 1 & ",""PO + Req'n"")"

If you meant a single column then:-
VBA Code:
    sht.Range(Cells(firstRow, lastCol), Cells(lastRow, lastCol)).FormulaR1C1 = _
        "= SUMIFS(RC3:RC" & lastCol - 1 & ",R" & hdgRow & "C3:R" & hdgRow & "C" & lastCol - 1 & ",""PO + Req'n"")"
 
Upvote 0
Solution

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi Alex

Thats perfect. It now does exactly what I want.

Thank you for your support it has been very much appreciated.

coop123
 
Upvote 0

Forum statistics

Threads
1,214,586
Messages
6,120,402
Members
448,958
Latest member
Hat4Life

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