mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,600
Office Version
  1. 365
Platform
  1. Windows
I am wanting to get a value from a table by using the SUMIFS function within a VBA routine

I am using the following code
Code:
Application.WorksheetFunction.SumIfs(rngAssFTE, rngAssPerson, strPerson, rngAssRole, strRole, rngAssDate, ">=" & dtRoleStart, rngAssDate, "<=" & dtRoleEnd)
to get what should be a value of 168 but it is returning 0.

When I recreate this in Excel using the formula - SUMIFS(tbl_Assigned[Assigned],tbl_Assigned[Name],Resource!B5,tbl_Assigned[Role],Resource!C5,tbl_Assigned[Date],">="&Resource!E5,tbl_Assigned[Date],"<="&Resource!F5)

I get the correct result.

I have checked and triple checked that the ranges in the VBA function are correct and the string and date values are also correct.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I think we need more input here. Do you want to use the result for a variable? do you want the script to write the value in a cell? VBA is not that intuitive, it differs what you'd do in vba from what you'd write in the cells.
 
Upvote 0
Someone far more inteliigent than me could maybe explain but when dealing with dates i always dimension them to long.

Code:
Dim dtRoleStart As Long, dtRoleEnd As Long

See if that works.
 
Upvote 0
Well spank my ar*e and call me susan!!!

Thanks Steve....I must have spent 2 hours trying to see what the problem is here and that has fixed it!! Excel can be a d*ck sometimes!!!!
 
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

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