I have created a staff holiday planner and need it to show the number of days taken by each employee against a range of codes i.e. "H" full day, "h" half day, "S" sick etc. I am using the countif function however have not yet managed to get it to respond to case. Can this be done? please help
[SOLVED]Can Countif be case sensitive
-
-
-
Re: Can Countif be case sensitive
I do not think it is possible to get COUNTIF to be case sensitive, but you could use:
=SUMPRODUCT(EXACT(D1:D6,"h")*1)
Where D1:D6 is holding your codes.
HTH
TJ
-
Re: Can Countif be case sensitive
JP2004,
or this function which is a simplified version of countif for your situation:
CodePublic Function CountifCaseSensitive(rngEvaluate As Range, _ strCriteria As String) As Long Dim rng As Range Dim lngCount As Long lngCount = 0 For Each rng In rngEvaluate If rng = strCriteria Then lngCount = lngCount + 1 Next rng CountifCaseSensitive = lngCount End Function
A.
-
Re: Can Countif be case sensitive
just the ticket, many thanks.
-
Re: Can Countif be case sensitive
Hi A9192Shark,
I'm not that familiar with VB; where within the VBA editor does the code go? Also what formula do I type into the formula bar once the code is in the right place? Does it work across all worksheets or just the one I apply the code to?I have attached a screen-shot of my VBA editor if this helps. Many thanks in advance.
[ATTACH=CONFIG]45683[/ATTACH]
Quote from A9192Shark;140530JP2004,
or this function which is a simplified version of countif for your situation:
CodePublic Function CountifCaseSensitive(rngEvaluate As Range, _ strCriteria As String) As Long Dim rng As Range Dim lngCount As Long lngCount = 0 For Each rng In rngEvaluate If rng = strCriteria Then lngCount = lngCount + 1 Next rng CountifCaseSensitive = lngCount End Function
A.
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!