ChetShannon
Board Regular
- Joined
- Jul 27, 2007
- Messages
- 133
- Office Version
- 365
- Platform
- Windows
Hi,
Am getting an error on my Case Select statement. The error message is - "Case without Select Case". And I could not figure out where the error was this Case Select which has about 7 different possible "Cases" and so I removed each Case one by one to see which one was causing the error message and what I have below is the one causing the error message because the code seems to run fine without this one section Not sure what's wrong with it . Any help would be appreciated.
Section causing the error-
Am getting an error on my Case Select statement. The error message is - "Case without Select Case". And I could not figure out where the error was this Case Select which has about 7 different possible "Cases" and so I removed each Case one by one to see which one was causing the error message and what I have below is the one causing the error message because the code seems to run fine without this one section Not sure what's wrong with it . Any help would be appreciated.
Section causing the error-
Code:
Case "Time Changed, Equipment Type"
If Cells(RowY, 13) = HomeLoc Then
'departure case
If DeptTm1 = DeptTm2 And Equip1 = Equip2 Then OutputText = ""
If DeptTm1 = DeptTm2 Then
'equip only changed
OutputText = "Flt" & FltNbr2 & " " & Dow1 & " changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & _
" to " & Format(DeptTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & _
" to " & Format(DeptTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'End If
If DeptTm1 > DeptTm2 Then Cells(RowY, 26) = -24 * 60 * (DeptTm1 - DeptTm2) Else Cells(RowY, 26) = 24 * 60 * (DeptTm2 - DeptTm1)
Else
'arrival case
If ArvlTm1 = ArvlTm2 And Equip1 = Equip2 Then OutputText = ""
If ArvlTm1 = ArvlTm2 Then
'equip only changed
OutputText = "Flt" & FltNbr2 & " " & Dow1 & " changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Arv time change from " & Format(ArvltTm1, "hhmm") & _
" to " & Format(ArvlTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
If ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Arv time change from " & Format(ArvlTm1, "hhmm") & _
" to " & Format(ArvlTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'End If
If ArvlTm1 > ArvlTm2 Then Cells(RowY, 26) = -24 * 60 * (ArvlTm1 - ArvlTm2) Else Cells(RowY, 26) = 24 * 60 * (ArvlTm2 - ArvlTm1)
End If
[U][B]***The entire Case Select section including the error section I show above. ********[/B][/U]
Select Case TypeNow
Case "Delete"
OutputText = "Flt" & FltNbr1 & " Deleted " & Orgn1 & "-" & Dest1 & " " & Dow1
Case "Add"
If Orgn2 = HomeLoc Then
OutputText = "Flt" & FltNbr2 & " Added " & Orgn2 & "-" & Dest2 & " dept " & Format(DeptTm2, "hhmm") & " " & Dow2
Else
OutputText = "Flt" & FltNbr2 & " Added " & Orgn2 & "-" & Dest2 & " arvl " & Format(ArvlTm2, "hhmm") & " " & Dow2
End If
Case "Time Changed"
If Cells(RowY, 13) = HomeLoc Then
If DeptTm1 = DeptTm2 Then OutputText = "" Else OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & " to " & Format(DeptTm2, "hhmm") & " " & Dow2
If DeptTm1 > DeptTm2 Then Cells(RowY, 26) = 24 * 60 * (DeptTm1 - DeptTm2) Else Cells(RowY, 26) = -24 * 60 * (DeptTm2 - DeptTm1)
Else
If ArvlTm1 = ArvlTm2 Then OutputText = "" Else OutputText = "Flt" & FltNbr2 & " Arv time change from " & Format(ArvlTm1, "hhmm") & " to " & Format(ArvlTm2, "hhmm") & " " & Dow2
If ArvlTm1 > ArvlTm2 Then Cells(RowY, 26) = -24 * 60 * (ArvlTm1 - ArvlTm2) Else Cells(RowY, 26) = 24 * 60 * (ArvlTm2 - ArvlTm1)
End If
Case "Days of Week"
OutputText = "Flt" & FltNbr2 & " Ops days changed from " & Dow1 & " to " & Dow2
Case "Equipment Change"
OutputText = "Flt" & FltNbr2 & " " & Dow1 & " changed from " & Equip1 & " to " & Equip2
Case "Days of Week, Time Changed"
'is departure case-
If Cells(RowY, 13) = HomeLoc Then
If DeptTm1 = DeptTm2 Then
'DOW only changed
OutputText = "Flt" & FltNbr2 & " " & Dow1 & " changed to " & Dow2
'DOW only because time change < minimum time to show-
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Dow1 & " to " & Dow2
'DOW only because time change < minimum time to show-
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Dow1 & " to " & Dow2
'time changed & DOW
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & _
" to " & Format(DeptTm2, "hhmm") & " changed from " & Dow1 & " to " & Dow2
'time changed & DOW
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & _
" to " & Format(DeptTm2, "hhmm") & " changed from " & Dow1 & " to " & Dow2
End If
If DeptTm1 > DeptTm2 Then Cells(RowY, 26) = -24 * 60 * (DeptTm1 - DeptTm2) Else Cells(RowY, 26) = 24 * 60 * (DeptTm2 - DeptTm1)
'is arrival case-
Else
If ArvlTm1 = ArvlTm2 Then
'DOW only changed
OutputText = "Flt" & FltNbr2 & " " & Dow1 & " changed to " & Dow2
'DOW only because time change < minimum time to show-
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Dow1 & " to " & Dow2
'DOW only because time change < minimum time to show-
ElseIf ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Dow1 & " to " & Dow2
'time changed & DOW
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(ArvlTm1, "hhmm") & _
" to " & Format(ArvlTm2, "hhmm") & " changed from " & Dow1 & " to " & Dow2
'time changed & DOW
ElseIf ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(ArvlTm1, "hhmm") & _
" to " & Format(ArvlTm2, "hhmm") & " changed from " & Dow1 & " to " & Dow2
End If
If ArvlTm1 > ArvlTm2 Then Cells(RowY, 26) = -24 * 60 * (ArvlTm1 - ArvlTm2) Else Cells(RowY, 26) = 24 * 60 * (ArvlTm2 - ArvlTm1)
End If
Case "Days of Week, Equip Change"
'For DOW change & Equip Type
If Dow1 = Dow2 Then
OutputText = "Flt" & FltNbr2 & " Ops days changed from " & Dow1 & " to " & Dow2
ElseIf Dow1 <> Dow2 Then OutputText = "Flt" & FltNbr2 & " Ops days changed from " & Dow1 & " to " & Dow2
End If
If RowY = 112 Then MsgBox ("Row112 reached")
'ERROR CAUSING SECTION BELOW ------>>>>>>>>>
Case "Time Changed, Equipment Type"
If Cells(RowY, 13) = HomeLoc Then
'departure case
If DeptTm1 = DeptTm2 And Equip1 = Equip2 Then OutputText = ""
If DeptTm1 = DeptTm2 Then
'equip only changed
OutputText = "Flt" & FltNbr2 & " " & Dow1 & " changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & _
" to " & Format(DeptTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & _
" to " & Format(DeptTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'End If
If DeptTm1 > DeptTm2 Then Cells(RowY, 26) = -24 * 60 * (DeptTm1 - DeptTm2) Else Cells(RowY, 26) = 24 * 60 * (DeptTm2 - DeptTm1)
Else
'arrival case
If ArvlTm1 = ArvlTm2 And Equip1 = Equip2 Then OutputText = ""
If ArvlTm1 = ArvlTm2 Then
'equip only changed
OutputText = "Flt" & FltNbr2 & " " & Dow1 & " changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'equip only because time change < minimum time to show-
ElseIf ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) < MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Arv time change from " & Format(ArvltTm1, "hhmm") & _
" to " & Format(ArvlTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'time changed & equip changed
If ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Arv time change from " & Format(ArvlTm1, "hhmm") & _
" to " & Format(ArvlTm2, "hhmm") & " changed from " & Equip1 & " to " & Equip2
'End If
If ArvlTm1 > ArvlTm2 Then Cells(RowY, 26) = -24 * 60 * (ArvlTm1 - ArvlTm2) Else Cells(RowY, 26) = 24 * 60 * (ArvlTm2 - ArvlTm1)
End If
'<<<-------------ERROR CAUSING SECTION ABOVE HERE
'For changed Days of Week, Equip Type, Time Changed (3 elements): Updated 2-5-2019 1345L
Case "Days of Week, Equipment Type, Time Changed"
If Cells(RowY, 13) = HomeLoc Then
'departure case
'times the same though on departure time
If DeptTm1 = DeptTm2 Then 'only indicating days of operation & equipment this sub-case
OutputText = "Flt" & FltNbr2 & " " & Dow1 & "to " & Dow2 & " changed from " & Equip1 & " to " & Equip2
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) < MinTimeToShow Then
'will be Ops_day, Equip type change only
OutputText = "Flt" & FltNbr2 & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) < MinTimeToShow Then
'will be Ops_day, Equip type change only
OutputText = "Flt" & FltNbr2 & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
ElseIf DeptTm1 > DeptTm2 And 24 * 60 * (DeptTm1 - DeptTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & " to " & _
Format(DeptTm2, "hhmm") & ", changed from " & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
ElseIf DeptTm2 > DeptTm1 And 24 * 60 * (DeptTm2 - DeptTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(DeptTm1, "hhmm") & " to " & _
Format(DeptTm2, "hhmm") & ", changed from " & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
End If
Else
'arrival case : Updated 2-6-2019 1400L
'times the same though on departure time
If ArvlTm1 = ArvlTm2 Then 'only indicating days of operation & equipment this sub-case
OutputText = "Flt" & FltNbr2 & " " & Dow1 & "to " & Dow2 & " changed from " & Equip1 & " to " & Equip2
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) < MinTimeToShow Then
'will be Ops_day, Equip type change only
OutputText = "Flt" & FltNbr2 & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
ElseIf ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) < MinTimeToShow Then
'will be Ops_day, Equip type change only
OutputText = "Flt" & FltNbr2 & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
ElseIf ArvlTm1 > ArvlTm2 And 24 * 60 * (ArvlTm1 - ArvlTm2) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(ArvlTm1, "hhmm") & " to " & _
Format(ArvlTm2, "hhmm") & ", changed from " & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
ElseIf ArvlTm2 > ArvlTm1 And 24 * 60 * (ArvlTm2 - ArvlTm1) >= MinTimeToShow Then
OutputText = "Flt" & FltNbr2 & " Dep time change from " & Format(ArvlTm1, "hhmm") & " to " & _
Format(ArvlTm2, "hhmm") & ", changed from " & Equip1 & " to " & Equip2 & " and ops days changed from " & _
Dow1 & " to " & Dow2
End If
If ArvlTm1 > ArvlTm2 Then Cells(RowY, 26) = -24 * 60 * (ArvlTm1 - ArvlTm2) Else Cells(RowY, 26) = 24 * 60 * (ArvlTm2 - ArvlTm1)
End If
End Select 'ends the Case Select statement group.
Last edited by a moderator: