Function GetStart(Name As String, Instance As Long) As Variant
Dim r As Long
Dim c As Long
Dim f As Boolean
Dim n As Long
Dim wsh As Worksheet
Dim cel As Range
GetStart = ""
Set wsh = Worksheets("Scheduale")
Set cel = wsh.Range("C4:C" & wsh.Rows.Count).Find(What:=Name, LookAt:=xlWhole, _
MatchCase:=False)
If cel Is Nothing Then Exit Function
r = cel.Row
For c = 6 To 65 ' F to BM
If wsh.Cells(r, c).Interior.Color = vbRed Then
If f = False Then
n = n + 1
If n = Instance Then
GetStart = wsh.Cells(3, c).Value
Exit Function
End If
f = True
End If
ElseIf f = True Then
f = False
End If
Next c
End Function
Function GetEnd(Name As String, Instance As Long) As Variant
Dim r As Long
Dim c As Long
Dim f As Boolean
Dim n As Long
Dim wsh As Worksheet
Dim cel As Range
GetEnd = ""
Set wsh = Worksheets("Scheduale")
Set cel = wsh.Range("C4:C" & wsh.Rows.Count).Find(What:=Name, LookAt:=xlWhole, _
MatchCase:=False)
If cel Is Nothing Then Exit Function
r = cel.Row
For c = 6 To 65 ' F to BM
If wsh.Cells(r, c).Interior.Color = vbRed Then
If f = False Then
n = n + 1
f = True
End If
ElseIf f = True Then
If n = Instance Then
GetEnd = wsh.Cells(3, c).Value
Exit Function
End If
f = False
End If
Next c
End Function