count ifs with date range from date time field

Imran Azam

Board Regular
Joined
Mar 15, 2011
Messages
103
HI Guys

i am doing a count ifs statement on the example data below

[TABLE="width: 261"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD][TABLE="width: 492"]
<tbody>[TR]
[TD]Name
[/TD]
[TD]Stats
[/TD]
[TD] date
[/TD]
[/TR]
[TR]
[TD]Alex
[/TD]
[TD]Qualified
[/TD]
[TD]30/03/2019 01:18:01
[/TD]
[/TR]
[TR]
[TD]Alex
[/TD]
[TD]Qualified
[/TD]
[TD]01/04/2019 10:08:01
[/TD]
[/TR]
[TR]
[TD]Alex
[/TD]
[TD]Not Qualified
[/TD]
[TD]30/04/2019 02:01:01
[/TD]
[/TR]
[TR]
[TD]Alex
[/TD]
[TD]Qualified
[/TD]
[TD]29/04/2019 16:18:01
[/TD]
[/TR]
[TR]
[TD]James
[/TD]
[TD]Not Qualified
[/TD]
[TD]26/001/2019 10:55:01
[/TD]
[/TR]
</tbody>[/TABLE]

[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

The logic i am using is count Name if name equals Alex and stats Qualified and date range is between 01/04/2019 and 30/04/2019 then count name and divide this by the count of name where name is alex and date range is between 01/04/2019 and 30/04/2019. the answer should be 2/3

from previous post io did i used the following formula but now the date field has date and time this doesnt work

=COUNTIFS(A2:A10,"Alex",B2:B10,"Qualified",C2:C10,">="&DATEVALUE("4/1/19"),C2:C10,"<="&DATEVALUE("4/30/19"))

can any one help me correct this formula?

thanks guys
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I think your formula is fine.. It may be an issue where your dates/times are reading as text and not a date value.
 
Upvote 0
This would give you a start... Highlight all of your date/time data and run this:
Code:
Sub Text2Date()

Dim cel As Range
Dim arr As Variant
Dim aDate As Variant


For Each cel In Selection
    arr = Split(cel.Value, " ")
    aDate = Split(arr(0), "/")
    'assuming date is in mm/dd/yyyy format
    cel = DateSerial(aDate(2), aDate(1), aDate(0)) + TimeValue(arr(1))
Next cel
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top