Hi
Any chance you could help me with one more thing...my code below keeps returning a runtime error 13 'type mismatch'. varX has been declared as a variant. Basically the error occurs when I (knowingly) try to do a vlookup on an empty cell. What's the best way to get around this - I just want to set varX = 0 if an error occurs?
Any chance you could help me with one more thing...my code below keeps returning a runtime error 13 'type mismatch'. varX has been declared as a variant. Basically the error occurs when I (knowingly) try to do a vlookup on an empty cell. What's the best way to get around this - I just want to set varX = 0 if an error occurs?
Code:
For j = 1 To UBound(strTheBoats)
varX = Application.IfError(Application.VLookup(Sheet2.Cells(j + 1, k + strTheBoats(i).MaxWait), Sheet1.Range("A:D"), 4, 0), 0)
dblHrsTotal = dblHrsTotal + varX
varX = Application.IfError(((Application.VLookup(Sheet2.Cells(j + 1, k + strTheBoats(i).MaxWait), Sheet1.Range("A:D"), 5, 0)) ^ 2), 0)
dblHrsVarTotal = dblHrsVarTotal + varX
Next j