Unable to copy formula down sheet if data isn't there.

CaptainGravyBum

Board Regular
Joined
Dec 1, 2023
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Morning,
I had some help with a formula on a previous post which is working well, but it will only work if there are the same number of rows every time. If I try to copy the formula down the sheet, all results will give me an error.
Is there a way round this? Basically, the number of rows will change depending on the data imported from another sheet, so the idea of the formula is that is will adjust accordingly.
If it's not possible to make the formula to adapt this way, I'm happy to add it as a macro when the sheet is activated, if someone can help me define the last row to update the formula each time.

Book1
ABCDE
1Article numberOrder numberCountOrder Count
2PBB12(MKM1)204021250 
3PBB12(MKM1)204021250500
4PFCF11E20401222
5PFCF11E20404566
6PFCF11E2039806060
7PFCF11E2040851010
8PBTF1220412510 
9PBTF1220412520 
10PBTF1220412550 
11PBTF1220412520100
12PBTF122041271010
13PFCF11E20313445 
14PFCF11E2031341560
15PBB12(JE1)204136500500
16PBTF122041361010
17PBB12(JE1)204225500500
18PBB12(JE1)204229500500
19PFCF11E2042841010
20PBTF122042785252
21TGB20427877
22PBB12(MKM1)20440230 
23PBB12(MKM1)204402300330
24PFCF11E20445022
Sheet1
Cell Formulas
RangeFormula
E2:E24E2=IF(COUNTIFS($A$2:$A$24,A2,$B$2:$B$24,B2)=COUNTIFS($A$2:$A2,A2,$B$2:$B2,B2), SUMPRODUCT(($A$2:$A$24=$A2)*($B$2:$B$24=$B2)*($D$2:$D$24)),"")
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
How about
Excel Formula:
=IF(COUNTIFS($A:$A,A2,$B:$B,B2)=COUNTIFS($A$2:$A2,A2,$B$2:$B2,B2), SUMIFS(D:D,A:A,A2,B:B,B2),"")
 
Upvote 1
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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