Report dealing with time & date calculations (Ugh!)

TheRookie

New Member
Joined
Dec 22, 2018
Messages
12
Hello all experts!
Below is a snip of a worksheet from a rather large workbook. What you see in the sheet columns is "Status," "Date & Time," "Calculated Value of change from previous status." "Comments," "Initials"
In general, this is an application (that should have been in a database instead), where a graphic representation of my factory can be clicked on. Basically a click in a cell brings up a form that allows user to change a status from "Running" to "UM-Notif," or any of several status options. When the user submits the form, VB will go to the last line, the next empty line actually, and write the new status selected, and the current date & time (in decimal format). Then calculate for the line above how long the machine was in the previous status. Some of what you see below is just click-through's (Qualify status below was just 18 seconds).

Qualify​
10/19/22 6:21​
0:00:18​
UM-Notif​
10/19/22 6:21​
1:27:49​
rear paddle tense missing​
UM-Maint​
10/19/22 7:49​
0:00:38​
UM-Comp​
10/19/22 7:50​
0:00:05​
changed both paddle cylinders and cleaned 208 fixture​
tl​
Qualify​
10/19/22 7:50​
0:00:05​
Running​
10/19/22 7:50​
10:11:46​
UM-Notif​
10/19/22 18:02​
0:04:05​
Wont run.
UM-Maint​
10/19/22 18:06​
0:00:17​
UM-Comp​
10/19/22 18:06​
1:46:57​
machine had to be put in home position​
td​
Qualify​
10/19/22 19:53​
0:00:04​
Running​
10/19/22 19:53​
9:50:39​
UM-Notif​
10/20/22 5:44​
2:49:39​
Door won't open on HMI
UM-Maint​
10/20/22 8:33​
0:00:04​
diagnose no start issue, marker z cylinder on rear was not in basic position, loose sensor​
kg​
UM-Comp​
10/20/22 8:33​
0:04:46​
Qualify​
10/20/22 8:38​
0:00:05​
Running​
10/20/22 8:38​
2:02:32​
UM-Notif​
10/20/22 10:41​
0:09:28​
Cleaning
UM-Maint​
10/20/22 10:50​
0:00:06​
UM-Comp​
10/20/22 10:50​
0:00:05​
Qualify​
10/20/22 10:50​
0:00:05​
Running​
10/20/22 10:50​
7:31:36​
UM-Notif​
10/20/22 18:22​
0:12:03​
UM-Maint​
10/20/22 18:34​
0:00:12​
UM-Comp​
10/20/22 18:34​
0:15:02​
no error found​
td​
Qualify​
10/20/22 18:49​
0:00:14​
Running​
10/20/22 18:50​

Here's my conundrum... Gosh how Excel stinks dealing with dates and times (that's how I justify it anyhow). I pull status-time each week; literally manually. For a one week report, times several machines, I actually manage to get this done in less than 30 minutes. Can anyone recommend a method for polling this type of data with VB and or a form? The basic hero or heroine (odd word) for me would be that I could enter some limits to the report like start date and time, followed by end date and time. Then the report would pull the data and place the collective "time in each status" as a total for that window. I've attempted this many times in various ways and keep getting all kinds of errors, essentially getting no where. One additional problem was how to handle "partial time." For example if I wanted to pull the data for 2nd shift for the week. This shift is 2pm to 10pm. In the form this time is going to be a machine is "Running" from the previous shift and it gets logged to "UM-Notif" (which stands for Unscheduled Maintenance - Notified: this means machine broke down and they notified maintenance). SO, at 2pm shift change, the machine has been "Running" since 10:50 AM, and get's logged UM-Notif at 6:22 PM (above this is 10/20/22 18:22). The machine was in a running state for 7 hours, 31 minutes, 36 seconds, but only 4:31:36 of that was part of 2nd shift. The same problem occurs at the end of the shift, whether the status is running or UM-something, etc.

Sigh, and my apologies in advance for the heavy and lengthy explanation. I will appreciate any and all inputs.
Shawn
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Not sure I understand the shift issue. If you want to know up/down time per shift then the 4 hours makes sense to me. I guess it depends on what's more important - machine availability (includes time the machine was available to run even if it wasn't running), or down time, or count of downtime starts in a shift (to find problem shifts), or what. Maybe your rows ought to have 3 or 4 columns that make up a complete record. But I wouldn't attempt this in Excel and agree - a db would be better, but that might only be my bias coming through.

As for date/times, if your data does not consist of proper date/time values duration over midnight is impossible to get. Too often, people separate date from time or don't even use the date and wonder why they can't get elapsed time over midnight.
 
Upvote 0
Are you talking about something like this?

When you change the yellow cells it would pull the appropriate information if it meets those criteria.

Book1
ABCDEFGHI
1Helper DateHelper Time
2Qualify10/19/22 6:2110/19/20226:210:00:18
3UM-Notif10/19/22 6:2110/19/20226:211:27:49rear paddle tense missing
4UM-Maint10/19/22 7:4910/19/20227:490:00:38
5UM-Comp10/19/22 7:5010/19/20227:500:00:05changed both paddle cylinders and cleaned 208 fixturetl
6Qualify10/19/22 7:5010/19/20227:500:00:05
7Running10/19/22 7:5010/19/20227:5010:11:46
8UM-Notif10/19/22 18:0210/19/202218:000:04:05Wont run.
9UM-Maint10/19/22 18:0610/19/202218:000:00:17
10UM-Comp10/19/22 18:0610/19/202218:001:46:57machine had to be put in home positiontd
11Qualify10/19/22 19:5310/19/202219:050:00:04
12Running10/19/22 19:5310/19/202219:059:50:39
13UM-Notif10/20/22 5:4410/20/20225:442:49:39Door won't open on HMI
14UM-Maint10/20/22 8:3310/20/20228:330:00:04diagnose no start issue, marker z cylinder on rear was not in basic position, loose sensorkg
15UM-Comp10/20/22 8:3310/20/20228:330:04:46
16Qualify10/20/22 8:3810/20/20228:380:00:05
17Running10/20/22 8:3810/20/20228:382:02:32
18UM-Notif10/20/22 10:4110/20/202210:040:09:28Cleaning
19UM-Maint10/20/22 10:5010/20/202210:050:00:06
20UM-Comp10/20/22 10:5010/20/202210:050:00:05
21Qualify10/20/22 10:5010/20/202210:050:00:05
22Running10/20/22 10:5010/20/202210:057:31:36
23UM-Notif10/20/22 18:2210/20/202218:020:12:03
24UM-Maint10/20/22 18:3410/20/202218:030:00:12
25UM-Comp10/20/22 18:3410/20/202218:030:15:02no error foundtd
26Qualify10/20/22 18:4910/20/202218:040:00:14
27Running10/20/22 18:5010/20/202218:05
28
29
30Date10/19/2022
31Start6:00
32End18:05
33
34Qualify10/19/22 6:2110/19/20226:210:00:1800
35UM-Notif10/19/22 6:2110/19/20226:211:27:49rear paddle tense missing0
36UM-Maint10/19/22 7:4910/19/20227:490:00:3800
37UM-Comp10/19/22 7:5010/19/20227:500:00:05changed both paddle cylinders and cleaned 208 fixturetl
38Qualify10/19/22 7:5010/19/20227:500:00:0500
39Running10/19/22 7:5010/19/20227:5010:11:4600
40UM-Notif10/19/22 18:0210/19/202218:000:04:05Wont run.0
41UM-Maint10/19/22 18:0610/19/202218:000:00:1700
42UM-Comp10/19/22 18:0610/19/202218:001:46:57machine had to be put in home positiontd
Sheet1
Cell Formulas
RangeFormula
C2:C27C2=VALUE(LEFT(B2,FIND(" ",B2)))
D2:D27D2=VALUE(MID(B2,9,5))
C34:I42C34=FILTER(A2:G27,(C2:C27=D30) * (D2:D27>=D31) * (D2:D27<=D32))
Dynamic array formulas.
 
Upvote 0
Here is an example if change the inputs:
Book1
CDEFGHI
30Date10/20/2022
31Start6:00
32End10:05
33
34UM-Maint10/20/22 8:3310/20/20228:330:00:04diagnose no start issue, marker z cylinder on rear was not in basic position, loose sensorkg
35UM-Comp10/20/22 8:3310/20/20228:330:04:4600
36Qualify10/20/22 8:3810/20/20228:380:00:0500
37Running10/20/22 8:3810/20/20228:382:02:3200
38UM-Notif10/20/22 10:4110/20/202210:040:09:28Cleaning0
39UM-Maint10/20/22 10:5010/20/202210:050:00:0600
40UM-Comp10/20/22 10:5010/20/202210:050:00:0500
41Qualify10/20/22 10:5010/20/202210:050:00:0500
42Running10/20/22 10:5010/20/202210:057:31:3600
Sheet1
Cell Formulas
RangeFormula
C34:I42C34=FILTER(A2:G27,(C2:C27=D30) * (D2:D27>=D31) * (D2:D27<=D32))
Dynamic array formulas.
 
Upvote 0
Sorry i think you also wanted to calculate the total time based on yellow inputs. That output would be below in red text. You can follow the formulas. Hope this is what you were looking for.

Book1
ABCDEFGHIJKL
1Helper DateHelper Time
2Qualify10/19/22 6:2110/19/20226:210:00:18
3UM-Notif10/19/22 6:2110/19/20226:211:27:49rear paddle tense missing
4UM-Maint10/19/22 7:4910/19/20227:490:00:38
5UM-Comp10/19/22 7:5010/19/20227:500:00:05changed both paddle cylinders and cleaned 208 fixturetl
6Qualify10/19/22 7:5010/19/20227:500:00:05
7Running10/19/22 7:5010/19/20227:5010:11:46
8UM-Notif10/19/22 18:0210/19/202218:000:04:05Wont run.
9UM-Maint10/19/22 18:0610/19/202218:000:00:17
10UM-Comp10/19/22 18:0610/19/202218:001:46:57machine had to be put in home positiontd
11Qualify10/19/22 19:5310/19/202219:050:00:04
12Running10/19/22 19:5310/19/202219:059:50:39
13UM-Notif10/20/22 5:4410/20/20225:442:49:39Door won't open on HMI
14UM-Maint10/20/22 8:3310/20/20228:330:00:04diagnose no start issue, marker z cylinder on rear was not in basic position, loose sensorkg
15UM-Comp10/20/22 8:3310/20/20228:330:04:46
16Qualify10/20/22 8:3810/20/20228:380:00:05
17Running10/20/22 8:3810/20/20228:382:02:32
18UM-Notif10/20/22 10:4110/20/202210:040:09:28Cleaning
19UM-Maint10/20/22 10:5010/20/202210:050:00:06
20UM-Comp10/20/22 10:5010/20/202210:050:00:05
21Qualify10/20/22 10:5010/20/202210:050:00:05
22Running10/20/22 10:5010/20/202210:057:31:36
23UM-Notif10/20/22 18:2210/20/202218:020:12:03
24UM-Maint10/20/22 18:3410/20/202218:030:00:12
25UM-Comp10/20/22 18:3410/20/202218:030:15:02no error foundtd
26Qualify10/20/22 18:4910/20/202218:040:00:14
27Running10/20/22 18:5010/20/202218:05
28
29
30Date10/20/2022
31Start6:00
32End10:05
33
34UM-Maint10/20/22 8:3310/20/20228:330:00:04diagnose no start issue, marker z cylinder on rear was not in basic position, loose sensorkg
35UM-Comp10/20/22 8:3310/20/20228:330:04:46001:32Total Time
36Qualify10/20/22 8:3810/20/20228:380:00:0500
37Running10/20/22 8:3810/20/20228:382:02:3200
38UM-Notif10/20/22 10:4110/20/202210:040:09:28Cleaning0
39UM-Maint10/20/22 10:5010/20/202210:050:00:0600
40UM-Comp10/20/22 10:5010/20/202210:050:00:0500
41Qualify10/20/22 10:5010/20/202210:050:00:0500
42Running10/20/22 10:5010/20/202210:057:31:3600
Sheet1
Cell Formulas
RangeFormula
C2:C27C2=VALUE(LEFT(B2,FIND(" ",B2)))
D2:D27D2=VALUE(MID(B2,9,5))
C34:I42C34=FILTER(A2:G27,(C2:C27=D30) * (D2:D27>=D31) * (D2:D27<=D32))
K35K35=(MAX(INDEX(C34#,0,4))-MIN(INDEX(C34#,0,4)))
Dynamic array formulas.
 
Upvote 0
Thank you Micron & Keef2!
Micron - obviously you understand UP-time (not broken) vs. Availability (other states like Qualifying, Change Overs, etc). And yes crossing midnight is a tough one (3rd shift). Would love to rewrite in Access, but alas, who has the time...
Keef2- Thanks!!! A million! I will try those all next week. And post results.
Very best regards - Shawn
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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