Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a variable assigned to Variant type and I have this statement before
The variable is assigned: On Error Goto XXXX THe variable gets its value as follows: Res = Application.VLookup(Cells(X, 1) & Cells(X, 41), LookupRng, 3, False) The result is error 42, but the application does not goto XXXX but instead I get an error 42, runtime error 13, type mismatch. I am not sure what to do I can't seem to get the program to just skip over the assignment. Suggestions? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Drop the "on error goto xxxx" and just check for an error:
dim Res as variant .... res = application.vlookup(...) if iserror(res) then 'you got an error else 'it wasn't an error end if Or You could use Dim res as variant on error goto xxxx: res = application.worksheetfunction.vlookup(...) on error goto 0 .... exit sub xxxx: msgbox "found an error" ======= There's a difference between the way application.vlookup() and application.worksheetfunction.vlookup() works. (same with application.match and application.worksheetfunction.match, fyi.) Mike H. wrote: I have a variable assigned to Variant type and I have this statement before The variable is assigned: On Error Goto XXXX THe variable gets its value as follows: Res = Application.VLookup(Cells(X, 1) & Cells(X, 41), LookupRng, 3, False) The result is error 42, but the application does not goto XXXX but instead I get an error 42, runtime error 13, type mismatch. I am not sure what to do I can't seem to get the program to just skip over the assignment. Suggestions? -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That solved my problem!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multiple variable issue | Excel Discussion (Misc queries) | |||
subroutine variable decleration issue | Excel Programming | |||
Object variable issue | Excel Programming | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
OutlineLevel and Integer Variable issue | Excel Programming |