How to extract Start and End time for a true/false event from a data sheet using vba code?

Syed Ahmad Ali Shah

New Member
Joined
Mar 10, 2023
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

I want to extract start and end time into separate columns from a data sheet based on shift timings as shown below;

Shift-1 timing = 06:31-14:30
Shift-2 timing = 14:31-22:30
Shift-3 timing = 22:31-06:30

Requirement:
Start Time (false condition) = ?
End Time (false condition) = ?

DateTimeEventShift
24/02/20236:30TRUE1
24/02/20236:35TRUE1
24/02/20236:40TRUE1
24/02/20236:45TRUE1
24/02/20236:50TRUE1
24/02/20236:55TRUE1
24/02/20237:00FALSE1
24/02/20237:05FALSE1
24/02/20237:10FALSE1
24/02/20237:15FALSE1
24/02/20237:20FALSE1
24/02/20237:25FALSE1
24/02/20237:30FALSE1
24/02/20237:35FALSE1
24/02/20237:40FALSE1
24/02/20237:45TRUE1
24/02/20237:50TRUE1
24/02/20237:55TRUE1
24/02/20238:00TRUE1
24/02/20238:05TRUE1
 
Thanks a lot for this so much guidance and support. Just guide me the last thing that how to automatically avail these entries in separate date wise files as shown below.

1678691705043.png

.. then it probably would have been a good idea to have explained that at the beginning and/or included an example like that. ;)

23 03 12.xlsm
ABCFGH
1DateTimeEventStartEndTotal
224/02/20236:30TRUE2023-02-24 07:00:002023-02-24 07:40:0000:40
324/02/20236:35TRUE2023-02-24 07:50:002023-02-24 08:00:0000:10
424/02/20236:40TRUE   
524/02/20236:45TRUE   
624/02/20236:50TRUE
724/02/20236:55TRUE
824/02/20237:00FALSE
924/02/20237:05FALSE
1024/02/20237:10FALSE
1124/02/20237:15FALSE
1224/02/20237:20FALSE
1324/02/20237:25FALSE
1424/02/20237:30FALSE
1524/02/20237:35FALSE
1624/02/20237:40FALSE
1724/02/20237:45TRUE
1824/02/20237:50FALSE
1924/02/20237:55FALSE
2024/02/20238:00FALSE
2124/02/20238:05TRUE
22
Start End
Cell Formulas
RangeFormula
F2:F5F2=IFERROR(AGGREGATE(15,6,(A$2:A$21+B$2:B$21)/((C$2:C$21=FALSE)*(C$1:C$20<>FALSE)),ROWS(F$1:F1)),"")
G2:G5G2=IFERROR(AGGREGATE(15,6,(A$2:A$21+B$2:B$21)/((C$2:C$21=FALSE)*(C$3:C$22<>FALSE)),ROWS(F$1:F1)),"")
H2:H5H2=IF(G2="","",G2-F2)
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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