VBA CountIfs ignores an argument

Asked at 2017-01-11 19:02:57Z
  • 5 Subscribers

I am having the following trouble with my Application.WorksheetFunction.CountIfs code bellow.

When I do the countifs making it look and count for the word "TER", it works.

When I do the countifs between the dates, it works.

When I put the arguments I said together it just count between the dates, it's like the countifs ignored the argument I want to count the word TER in the column. I researched a lot, and couldn't find something that helps. Already tried put two quotes in ""TER"".

Thank you.

Dim TerminPerio As Integer, IniRAM As Date, FimRAM As Date
Dim NecessTOT As Integer

IniRAM = #12/1/2016#           
FimRAM = #12/31/2016#

NecessTOT = Application.WorksheetFunction.CountIfs(Range("L:L"), "TER", Range("I:I"), ">=" & CDbl(IniRAM), Range("I:I"), "<=" & CDbl(FimRAM)) 
'NecessTOT = Application.WorksheetFunction.CountIfs(Range("L:L"), "TER")
'NecessTOT = Application.WorksheetFunction.CountIfs(Range("I:I"), ">=" & CDbl(IniRAM), Range("I:I"), "<=" & CDbl(FimRAM)) 

MsgBox (CStr(NecessTOT))

End Sub

0 answers in total

Answer this questsion