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

razzandy

Active Member
Joined
Jun 26, 2002
Messages
388
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 πŸŽ„πŸŽ„πŸŽ„πŸŽ„πŸŽ„
 

razzandy

Active Member
Joined
Jun 26, 2002
Messages
388
Office Version
  1. 2007
Platform
  1. Windows
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) & ")")
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,071
Office Version
  1. 365
Platform
  1. Windows
That should work, as long as the dates haven't already been converted to US dates.
 

razzandy

Active Member
Joined
Jun 26, 2002
Messages
388
Office Version
  1. 2007
Platform
  1. Windows
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!

πŸŽ„ πŸŽ… πŸŽ„ πŸŽ… β›„β„οΈβ˜ƒοΈβ„οΈβ›„β„οΈβ˜ƒοΈπŸ‚πŸ‚πŸ‚πŸŽΏβ›·οΈπŸ”οΈπŸ”οΈπŸ”οΈπŸŽ„πŸŽ„πŸŽ„πŸŽ„πŸŽ…πŸŽ…πŸŽ„πŸŽ„πŸ·πŸ·πŸ·πŸ·πŸ·πŸΊπŸΊπŸΊπŸΊπŸΊπŸΊπŸ»πŸ»πŸ»πŸ»πŸ»πŸ»
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,071
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback.
Have a good Xmas & NewYear as well.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,850
Messages
5,598,457
Members
414,239
Latest member
xnanx

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
Top