PDA

View Full Version : vba sumifs



prestopr
05-08-2012, 04:30 PM
I am seeking assistance with the worksheet function sumifs to sum the contents of a column if it meets multiple criteria.


It all works well until I introduce dates i.e. if between two dates.

Here is the relevant parts of the code.

Dim objLab As Range, objPit As Range, objSamples As Range, objmDate As Range
Dim strLab As String, strPit As String, strCost As String, strSamples As String, strsDate As String, streDate As String

'strSamples = WorksheetFunction.SumIfs(objSamples, objLab, strLab, objPit, strPit, objmDate, ">=" & strsDate, objmDate, "<=" & streDate)
'strCost = WorksheetFunction.SumIfs(objCost, objLab, strLab, objPit, strPit, objmDate, ">=" & strsDate, objmDate, "<=" & streDate)


any assistance would be greatly appreciated

geekgirlau
05-08-2012, 08:50 PM
Try using SUMPRODUCT instead.

Generally I'm not a fan of hardcoding formulas - have you thought about performing the calculations either on a hidden sheet or in a hidden column in your workbook instead?

Bob Phillips
05-09-2012, 01:04 AM
Show us the code that sets up those variables, that is probably where your problem lies.