SUMIF combined with Mid Function

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,601
Office Version
  1. 2021
Platform
  1. Windows
I have set up a sumif formula. I have tried to use the Mid Function within the sumif to extract the criteria instead of having to type the criteria, but it gives me zero-see formula below

=SUMIF($B$1:$B$9,"<"&MID(B18,30,18)&"",$E$1:$E$9)


If I type in the criteria, i get the correct result-see formula below

=SUMIF($B$1:$B$9,"<25/07/2011",$E$1:$E$9)

I have attached sample data below

It would be appreciated if you could assist me

Chapter 5.SUMIF.xls
ABCDEF
18TotalInvoiceamountsBefore25/07/20110.0011,597.00
Sheet1
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
try this
<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;">01/07/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">100</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">15/07/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">100</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;">25/07/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">100</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">01/08/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">100</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;">14/08/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">100</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;">14/08/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">100</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style=";">18
Total Invoice amounts Before 25/07/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;">300</td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">D8</th><td style="text-align:left">{=SUM(<font color="Blue">IF(<font color="Red">DATEVALUE(<font color="Green">RIGHT(<font color="Purple">B8,11</font>)</font>)>=B1:B6,E1:E6</font>)</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />
 
Upvote 0
Thanks for the help, formula works perfectly.

It is possible to change this formula so that it works in the normal =Sumif formula?
 
Upvote 0
Try something like this...

=SUMIF($B$1:$B$9,"<"&DATEVALUE(MID(B18,30,18)),$E$1:$E$9)

DATEVALUE converts the text date into a serial date.

This does the same thing...
=SUMIF($B$1:$B$9,"<"&MID(B18,30,18)*1,$E$1:$E$9)
 
Last edited:
Upvote 0
Thanks for the help, formula works perfectly.

It is possible to change this formula so that it works in the normal =Sumif formula?
Sa,e with Alpha Formula
=SUMIF(B1:B6,"<="&DATEVALUE(RIGHT(B8,11)),E1:E6)
 
Upvote 0
Hi try this simple example.
Excel Workbook
ABCD
1DateAmountTotal Amount Before 8/19/2011
28/14/2011100015000
38/15/20112000
48/16/20113000
58/17/20114000
68/18/20115000
78/19/20116000
88/20/20117000
Sheet1
Excel 2010
Cell Formulas
RangeFormula
D2=SUMIF(A2:A8,"<"&MID(D1,21,LEN(D1)-20)+0,B2:B8)
 
Upvote 0
Hi Yahya

Thanks for the help, formula works perfectly

Regards

Howard
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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