Sumifs will not work with Evaluate or Application.WorksheetFunction.SumIfs HELP!

razzandy

Active Member
Joined
Jun 26, 2002
Messages
390
Office Version
  1. 2007
Platform
  1. Windows
Hi Guys (Soon be Christmas) ??

I am traying to perform a Sumifs in VBA between two dates. If I use a standard formula on a sheet its works great:
Excel Formula:
=SUMIFS(B:B,A:A,">=17-11-2020",A:A,"<=23-11-2020")
. This gives me 98.

If I use:
VBA Code:
rTotLL = rTot.Evaluate("SUMIFS(B:B,A:A,"">=17-11-2020"",A:A,""<=23-11-2020"")")
I get Zero!

If I use:
VBA Code:
rTotLL = Application.WorksheetFunction.SumIfs(.Range("b2:b" & RW), .Range("a2:a" & RW), ">=17-11-2020", .Range("a2:a" & RW), "<=23-11-2020")
I still get Zero!

1608299997057.png


Any ideas what I'm doing wrong?

Have a good Weekend Guys ?????
 
In that case I would simply change the declaration from Date to Long
Again, another great idea but that would create some reworking of other, older produced code. So what do you think of the below workaround? Can you foresee any potential issues?

VBA Code:
Evaluate("SUMIFS(B:B,A:A,"">=""&" & CLng(SD) & ",A:A,""<=""&" & CLng(PD) & ")")
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
That should work, as long as the dates haven't already been converted to US dates.
 
Upvote 0
That should work, as long as the dates haven't already been converted to US dates.
Have great weekend Fluff and if we don't chat again before Christmas have a great Christmas and New Year!

? ? ? ? ⛄❄️☃️❄️⛄❄️☃️????⛷️?️?️?️?????????????????????????
 
Upvote 0
Glad to help & thanks for the feedback.
Have a good Xmas & NewYear as well.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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