SUMIFS criteria 1st through 3rd digits =??

jkream

New Member
Joined
Jul 14, 2016
Messages
10
I am writing a macro to return the sum of the amounts in a column C (CHECK_AMT) when the criteria in column B are met. I am having trouble differentiating the column B (FILENO) results:

FILENOCHECK_AMT
100X2943175
100X3076200
100X69225
11BB4725
1B1083150
1B126625
1B99210
227X9617
24X10820
336X1301150
336X1683250
336X2037100
362X1275
369X154950
369X244250
425A2993100
425A3090200
425A320250
425B27225
4AA429450
4AA1868150
4AA236750
4BB1289500
4BB132650
4CC111510
4CC137650
4CC1456125
4CC912250
4DD13540
4DD161250
4DD27925
4DD53612.5
4DD54525
4DD99965
4Z20650
4Z7580
4Z7680
900G116120
900G125940
900G1830
90X3750

<tbody>
</tbody>

The first set of numbers in the file number is the client, the rest is useless. I need to sum by client. The number of rows will be variable, so I would like to select ALL of rows in each column without hard coding the range.
ie: I need to sum all the values if the file number begins with ONLY a 4, NOT 426 or 425, or 90, but NOT 900, 1,11, and 100 are all to be separate.
For this I am only summing the 4's and the 900's but show me once and I can expand on it if I need to.
I am writing this in Excel 2013, but one of my users is running 2003 and it has to be compatible.
This is my first attempt at VB Macros. Any help is appreciated.
 
Oh sorry I forgot a part, you have to change the length for LEFT to accommodate the length of the number

Code:
Range("K4").Formula = "=SUMPRODUCT(--(LEFT(A1:A" & x & ",2)=""90""),1-(ISNUMBER(MID(A1:A" & x & ",3,1)+0)),B1:B" & x & ")"
 
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.
Oh sorry I forgot a part, you have to change the length for LEFT to accommodate the length of the number

Code:
Range("K4").Formula = "=SUMPRODUCT(--(LEFT(A1:A" & x & ",2)=""90""),1-(ISNUMBER(MID(A1:A" & x & ",3,1)+0)),B1:B" & x & ")"

This is Awesome, thank you so much for your effort.
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,317
Members
449,218
Latest member
Excel Master

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