Nov 09 2023 12:07 PM
I need to convert every 15 minutes worked into a whole number Unit, rounding down if it hasn't reached the 15 minute increment. Issue being that the times worked are not easy to measure as I may be working for 2 minutes, then later 8 minutes, and then later 30 minutes. I currently have it expressed as shown in Column A on the attached Excel sheet, and I manually add up the time at the end of the day or whenever I need it and enter the information into Column B. If anyone has an easy solution that wouldn't add too many extra cells, it would be appreciated.
Nov 09 2023 03:36 PM
SolutionSee the attached for a solution using a custom VBA function. You'll have to allow macros when you open the workbook.
Nov 09 2023 07:19 PM
Nov 09 2023 09:43 PM - edited Nov 09 2023 10:00 PM
@jacobconnell There's also a few formulas you could try, depending on if certain conditions are always true...
(1) If "AM" is always omitted and "PM" is always entered (ie: 10:50-11:07, 11:49-1:23PM, 1:38PM-1:45PM), use the following formula:
=ROUND(SUM(MMULT(--TRIM(TEXTSPLIT(SUBSTITUTE(A2, "PM", " PM"), "-", ",", TRUE)), {-1;1}))*96, 0)
(2) If "AM" is also sometimes entered (ie: 11:49AM-1:23PM), use an additional SUBSTITUTE function as follows:
=ROUND(SUM(MMULT(--TRIM(TEXTSPLIT(SUBSTITUTE(SUBSTITUTE(A2, "AM", " AM"), "PM", " PM"), "-", ",", TRUE)), {-1;1}))*96, 0)
Note: the SUBSTITUTE function is required in both of the formulas shown above because "1:00PM", for example, is not recognized as a valid time in Excel, whereas "1:00 PM" is.
(3) Regarding your additional inquiry about eliminating both "AM" and "PM" altogether, as long as there will never be a single time range greater than or equal to 12 hours (ie: 8:00-7:59 at the most), you could use the following formula:
=LET(arr, --TRIM(TEXTSPLIT(A2, "-", ",", TRUE)), ROUND(SUM(MOD(DROP(arr,,1)-TAKE(arr,,1), 0.5))*96, 0))
For example, 11:49-1:23 will return a value of 6, representing 6 intervals of 15 minutes.
Nov 09 2023 10:02 PM