Using COUNTIF to fill in Time vs Date grid from date+time field

svendfj

Board Regular
Joined
Mar 19, 2011
Messages
99
Office Version
  1. 2016
Platform
  1. Windows
Cells A1:A20 of Sheet1 is a date and time field. As shown below and in the attached image, Cells A1:F5 of Sheet2 is a grid with time in Row 1 and Dates in Column A. Specifically, cells B1:F1 = 8, 9, 19, 11, 12 and cells A2:A5 = 1-Apr, 2-Apr, 3-Apr and 4-Apr.

I would like to enter formulas in cells B2:F5 of Sheet2 so that, for example, cell B2 calculates the number of cells in Column A of Sheet1 that fall between the time range of 8 AM to 9 AM on 1-Apr. Similarly, cell F5 on Sheet2 calculates the number of cells in Column A of Sheet1 that are between 11-12 AM on 4-Apr.

Many thanks for any guidance on how to best do this.

Sheet1 Cells A1:A20
4/1/23 8:21 AM
4/1/23 8:46 AM
4/1/23 9:01 AM
4/1/23 10:44 AM
4/2/23 8:55 AM
4/2/23 9:03 AM
4/2/23 11:33 AM
4/2/23 11:37 AM
4/2/23 11:44 AM
4/3/23 8:05 AM
4/3/23 8:09 AM
4/3/23 9:21 AM
4/3/23 10:22 AM
4/3/23 11:04 AM
4/4/23 8:59 AM
4/4/23 9:11 AM
4/4/23 9:21 AM
4/4/23 11:08 AM
4/4/23 11:10 AM
4/4/23 11:55 AM

Sheet2 Cells A1:F5
89101112
1-Apr
2-Apr
3-Apr
4-Apr
 

Attachments

  • Time vs Date Grid.png
    Time vs Date Grid.png
    60.7 KB · Views: 2

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Assuming that all your dates in column A on each sheet are entered as valid date/times, place this formula in cell B2 on Sheet2:
Excel Formula:
=COUNTIFS(Sheet1!$A$1:$A$20,">=" & $A2+(B$1/24),Sheet1!$A$1:$A$20,"<" & $A2+((B$1+1)/24))
and copy to the rest of the range (B2:F5)
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,215,139
Messages
6,123,259
Members
449,093
Latest member
Vincent Khandagale

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