asked on # Excel Work Schedule Question

I have an Excel spreadsheet (attached) that is a visual scheduling for employees. The "x's" in the spreadsheet designate each 15 minute period the employee is scheduled for.

I just want a formula (no arrays, please) that can find the first "x" in the column, and return the corresponding starting time, along with the last "x" in the column, and return the corresponding ending time.

My spreadsheet is attached. Thanks in advance for helping make my scheduling job easier!

Thanks.

Schedule-EE.xlsx

I just want a formula (no arrays, please) that can find the first "x" in the column, and return the corresponding starting time, along with the last "x" in the column, and return the corresponding ending time.

My spreadsheet is attached. Thanks in advance for helping make my scheduling job easier!

Thanks.

Schedule-EE.xlsx

Microsoft ExcelSpreadsheetsMicrosoft Office

View this solution by signing up for a free trial.

Members can start a 7-Day free trial and enjoy unlimited access to the platform.

SHS' solution probably works but here's a UDF. If you need help implementing it let me know.

Usage:

To get the hours for employee "AL"

**=gethours(8)** 8 is the column number

Usage:

To get the hours for employee "AL"

```
Function GetHours(EmpCol As Integer) As String
Dim lngRow As Long
Dim lngStart As Long
With ActiveSheet
For lngRow = 9 To .UsedRange.Rows.Count
If .Cells(lngRow, EmpCol) = "+" Then
lngStart = lngRow
Exit For
End If
Next
For lngRow = lngStart + 1 To .UsedRange.Rows.Count
If .Cells(lngRow, EmpCol) = "" Then
lngRow = lngRow - 1
Exit For
End If
Next
GetHours = .Cells(3, EmpCol) & " " & .Cells(lngStart, "A").Text & " to " & .Cells(lngRow, "B").Text
End With
End Function
```

Martin: Yes ... they were "+" and not "x" signs ... my bad. Sorry for that. The blank shaded cells are the possible "overage" hours the employees could work, and the shaded with "+" signs are the actual scheduled hours. And I really needed a formula, not a UDF, but thank you, though!

Saqib: Your formula is perfect. It does exactly what I need it to. Thank you!

Saqib: Your formula is perfect. It does exactly what I need it to. Thank you!

Martin: Yes ... they were "+" and not "x" signs ... my bad. Sorry for that. The blank shaded cells are the possible "overage" hours the employees could work, and the shaded with "+" signs are the actual scheduled hours. And I really needed a formula, not a UDF, but thank you, though!

Saqib: Your formula is perfect. It does exactly what I need it to. Thank you!

Saqib: Your formula is perfect. It does exactly what I need it to. Thank you!

My solution will be via a user defined function which you will be able to use exactly like a formula, but it will require saving the workbook in xlsm format. Is that OK?