How to Transpose Work Schedule Data and Assign Shift Codes in Excel
Question details
The user needs to transform imported text containing employee schedules into a horizontal layout, extract start and end times, and assign shift codes for active hours against a timeline.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Managing and formatting employee shift schedules imported from text into a structured spreadsheet timeline.
- Observed behavior
- The user wants a dynamic formula solution to accurately parse shift times, account for overnight shifts, and correctly flag active periods across a horizontal timeline.
Ensure your timeline row is formatted properly as Time values and that your version of Excel supports dynamic array functions such as LET, TEXTBEFORE, and HSTACK.
Use Dynamic Array Functions to Parse and Transpose Schedules
Utilize the LET function to streamline the parsing of start/end times and horizontally stack the results with your timeline.
This approach uses the LET function to define variables for clock-in and clock-out times, calculates adjustments for overnight shifts, and outputs an array checking active hours against a horizontal timeline.
Use IFERROR(MOD(TEXTBEFORE(clockData,"-"),1),"Off") to extract the start time before the hyphen and convert it to a true time value.
Use MOD(TEXTAFTER(clockData,"-"),1) to extract the end time located after the hyphen.
Create an 'adjusted' variable using N(clockout<clockin) to add 1 day to the clock-out time if the shift crosses midnight.
Use HSTACK to combine the employee name, clock-in time, and the logical test (timeline>=clockin)*(timeline<=clockout+adjusted) to flag active hours.
Combine all parts: =LET(clockin,IFERROR(MOD(TEXTBEFORE(clockData,"-"),1),"Off"),clockout,MOD(TEXTAFTER(clockData,"-"),1),adjusted,N(clockout<clockin),IFERROR(HSTACK(name,clockin,(timeline>=clockin)*(timeline<=clockout+adjusted)),""))

Transpose and Analyze Schedules with WPS Spreadsheet
WPS Spreadsheet fully supports advanced array functions, providing a seamless environment for managing complex employee schedules and data transformations without any lag.
- 1. Open your data: Launch WPS Spreadsheet and open the file containing your raw text schedule data.
- 2. Select the target cell: Click the top-left cell where you want your dynamic horizontal timeline to start spilling.
- 3. Enter the array formula: Type or paste the LET formula to parse the times and generate the horizontal array.
- 4. Apply and analyze: Press Enter to let the dynamic array automatically spill across the necessary columns, giving you a clear view of your shift schedules.

Frequently Asked Questions
Why do my extracted times appear as generic text instead of time values?
Text functions like TEXTBEFORE return text strings. Wrapping them in the MOD function with a divisor of 1 (e.g., MOD(..., 1)) forces the spreadsheet application to convert the text string into a recognizable serial time value.
How does the formula handle shifts that cross midnight?
The formula uses N(clockout<clockin) to evaluate if the clock-out time is mathematically smaller than the clock-in time. If true, it returns 1, effectively adding one day to the clock-out time so the logic works correctly.
Can I replace the 1s and 0s in the timeline with a specific shift code?
Yes. You can multiply the boolean logic array ((timeline>=clockin)*(timeline<=clockout+adjusted)) by the specific shift code string, or incorporate an IF statement to return custom text like "Shift A" instead of 1.
What versions of Excel support the LET and HSTACK functions?
LET and HSTACK are dynamic array functions available in Microsoft 365 and Excel 2021 or later. If you are using an older version, you may need to rely on complex nested IFs and manual cell copying, or switch to a modern alternative like WPS Office.




