Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I have this code:
Any on e or more line may error when the vlookup fails to find the lookup value.
What kind of error checking code could I use to ignore the error associated with an inability to match and just simply move to the next line?
Code:
With uf9_poststaff
.cu2_start.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu2_en.Value), rg_staff, 5, False), "hh:mm")
.cu2_end.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu2_en.Value), rg_staff, 6, False), "h:mm")
.cu2_hours.Value = format(DateDiff("h", .cu2_end.Value, .cu2_start.Value) / 24, "standard")
.cu3_start.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu3_en.Value), rg_staff, 5, False), "hh:mm")
.cu3_end.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu3_en.Value), rg_staff, 6, False), "h:mm")
.cu3_hours.Value = format(DateDiff("h", .cu3_end.Value, .cu3_start.Value) / 24, "standard")
.wprk1_start.Value = format(Application.WorksheetFunction.VLookup(CLng(.wprk1_en.Value), rg_staff, 5, False), "hh:mm")
.wprk1_end.Value = format(Application.WorksheetFunction.VLookup(CLng(.wprk1_en.Value), rg_staff, 6, False), "h:mm")
.wprk1_hours.Value = format(DateDiff("h", .wprk1_end.Value, .wprk1_start.Value) / 24, "standard")
.wbvd1_start.Value = format(Application.WorksheetFunction.VLookup(CLng(.wbvd1_en.Value), rg_staff, 5, False), "hh:mm")
.wbvd1_end.Value = format(Application.WorksheetFunction.VLookup(CLng(.wbvd1_en.Value), rg_staff, 6, False), "h:mm")
.wbvd1_hours.Value = format(DateDiff("h", .wbvd1_end.Value, .wbvd1_start.Value) / 24, "standard")
.cu4_start.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu4_en.Value), rg_staff, 5, False), "hh:mm")
.cu4_end.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu4_en.Value), rg_staff, 6, False), "h:mm")
.cu4_hours.Value = format(DateDiff("h", .cu4_end.Value, .cu4_start.Value) / 24, "standard")
.cu5_start.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu5_en.Value), rg_staff, 5, False), "hh:mm")
.cu5_end.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu5_en.Value), rg_staff, 6, False), "h:mm")
.cu5_hours.Value = format(DateDiff("h", .cu5_end.Value, .cu5_start.Value) / 24, "standard")
.cu6_start.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu6_en.Value), rg_staff, 5, False), "hh:mm")
.cu6_end.Value = format(Application.WorksheetFunction.VLookup(CLng(.cu6_en.Value), rg_staff, 6, False), "h:mm")
.cu6_hours.Value = format(DateDiff("h", .cu6_end.Value, .cu6_start.Value) / 24, "standard")
End With
Any on e or more line may error when the vlookup fails to find the lookup value.
What kind of error checking code could I use to ignore the error associated with an inability to match and just simply move to the next line?