1

Hey guys i am trying to search a column of dates and count how many fall between two dates. I get an error Type mismatch when i run it.

Dim iVal As Integer
iVal = Application.WorksheetFunction.CountIfs("Incident_stats!k:k", ">=" & B1, "Incident_stats!k:k", "<=" & B2)
Range("D1").Value = iVal
1
  • Nope still same error Commented Mar 10, 2016 at 11:23

1 Answer 1

2

Countifs requires Range objects, not address strings:

iVal = Application.WorksheetFunction.CountIfs(Range("Incident_stats!k:k"), ">=" & Range("B1"), Range("Incident_stats!k:k"), "<=" & Range("B2"))

I assumed the B1 and B2 were cells too, rather than variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.