Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,665
- Office Version
- 365
- 2016
- Platform
- Windows
Can someone help me identify and resolve an "Object variable or With Block variable not set" error I am receiving with the code highlighted in red below. This is a combobox change event.
cb_r2_crew = "HPL"
"HPL1" exists in ws_vh, cell R30. The vlookup value (column 4) at U30 = 0.56
Rich (BB code):
Private Sub cb_r2_crew_change()
Dim mbEvents As Boolean
mbEvents = True
Dim sel_crew1_start As String
Dim sel_crew1_end As String
Dim sel_crew2_start As Variant
Dim sel_crew2_end As Variant
Dim lrtime As Double
Dim urtime As Double
Dim sh_el As String
sh_el = ""
sel_crew1_start = WorksheetFunction.VLookup(Me.cb_r2_crew & "1", ws_vh.Range("R25:V42"), 4, False)
sel_crew1_end = WorksheetFunction.VLookup(Me.cb_r2_crew & "1", ws_vh.Range("R25:V42"), 5, False)
sel_crew2_start = Application.VLookup(Me.cb_r2_crew & "2", ws_vh.Range("R25:V42"), 4, False)
If IsError(sel_crew2_start) Then
sh_el = "X"
Else
sel_crew2_end = WorksheetFunction.VLookup(Me.cb_r2_crew & "2", ws_vh.Range("R25:V42"), 5, False)
sh_el = WorksheetFunction.VLookup(Me.cb_r2_crew & "2", ws_vh.Range("R25:V42"), 2, False)
End If
lrtime = TimeValue(Me.tb_r2_sru)
urtime = TimeValue(Me.tb_r2_srl)
If WorksheetFunction.VLookup(Me.cb_r2_crew & "1", ws_vh.Range("R25:V42"), 2, False) = "X" And sh_el = "X" Then
MsgBox "No staff scheduled on this crew"
Exit Sub
End If
If lrtime > sel_crew1_end Then 'crew 1 can't
MsgBox "This tournament service is scheduled for after this crew has left."
Exit Sub
ElseIf lrtime < sel_crew1_start Then 'crew 1 can't
MsgBox "This tournament service is scheduled before this crew starts."
Exit Sub
End If
If sh_el <> "X" Then 'only crew 1
If lrtime > sel_crew2_end Then 'crew 1 can't
MsgBox "This tournament service is scheduled for after this crew has left."
Exit Sub
ElseIf lrtime < sel_crew2_start Then 'crew 1 can't
MsgBox "This tournament service is scheduled before this crew starts."
Exit Sub
End If
End If
mbEvents = False
End Sub
cb_r2_crew = "HPL"
"HPL1" exists in ws_vh, cell R30. The vlookup value (column 4) at U30 = 0.56