Retail store rota help

I want to build a new type of rota for my retail store, I want to do something like type in a persons shift, 12-4 for example, and the result to be 4, hours worked etc… I don’t mind typing in all of our different shift patterns to have as a template but can’t figure it out

How to understand the example? Do you intend to use a 12-hour nottion? Is the solution expected to guess correctly the AM/PM case? How many milliseconds do you expect to save per one entered shift doing it this way instead of using two adjacent cells for start and end?
(Never use 12-hour-notation, in specific not in such a context. It’s much too error-prone. Never trust in software pretending to guess correctly. Even the highly appreciated @JohnSUN cannot guarantee correctness insofar.)

It seams to me that you looking a UDF (“User Defined Function”) like this

Function getHours(sSource As String) As Double
Rem (©) Vladislav Orlov aka JohnSUN, Kyiv, 2017
Rem mailto:johnsun at i dot ua
Dim res As Double
Dim aStrings As Variant
Dim startTime As Double, finishTime As Double
Dim startH As Integer, finishH As Integer
Dim startM As Double, finishM As Double
	res = 0
	aStrings = Split(sSource, "-")
	If UBound(aStrings) = 1 Then    ' if we have 2 and only 2 value!
	    startTime = Val(aStrings(0))
	    finishTime = Val(aStrings(1))
	    startH = Int(startTime)
	    finishH = Int(finishTime)
	    startM = (startTime - startH) * 100 / 60
	    finishM = (finishTime - finishH) * 100 / 60
	    If (startTime < finishTime) Then
	        res = res + (Int(finishTime) + finishM) - (Int(startTime) + startM)
	    Else
	        res = res + (Int(finishTime) + finishM) - (Int(startTime) + startM) + IIf((startTime>13) Or (finishTime>13), 24, 12)
	    End If
	End If
    getHours = res
End Function

Usage getHours()

Epic, thank you very much! Will save a lot of time.

So “mark answer as correct” (tick in top left corner) - it will can help other users to find this answer :slight_smile: Was glad to help!