Reputation: 11
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
Upvotes: 1
Views: 71
Reputation: 11
Thanks for helping, everybody. My solution for my counts was doing something else: In a brief, to get the result i wanted, I did some sequential autofilters to the columns, copied the lines affected and counted the number of registers with another command line.
Example:
Selection.AutoFilter
ActiveSheet.Range("$L$1:$L" & LR).AutoFilter Field:=27, Criteria1:=CStr(MESRAM)
ActiveSheet.Range("$AK$1:$AK" & LR).AutoFilter Field:=28, Criteria1:=CStr(ANORAM)
ActiveSheet.Range("$AE$1:$AE" & LR).AutoFilter Field:=29, Criteria1:=CStr(MESRAM)
LR = Cells(Rows.Count, "A").End(xlUp).Row
Upvotes: 0