View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Ghost in the Machine - 1004 Vlookup & On Error Duo Trouble

Say A1 contains:
cat

and F1 thru G11 contain:

dog 1
cat 2
mouse 3
rat 4
house 5
flea 6
flower 7
fish 8
tree 9
bush 10
car 11

then in the worksheet the formula:
=VLOOKUP(A1,F1:G11,2,FALSE) will return a 2


In VBA, use Application and not Application.Worksheet function.

Also make sure Vlookup understands the type of the arguments:

Sub vlookupDemo()
Range("B9").Value = Application.VLookup(Range("A1"), Range("F1:G11"), 2, 0)
End Sub

will also find the same 2
--
Gary''s Student - gsnu200854


"VBANovice" wrote:

Dear,

I am afraid this is definetly not a cure for my Ghost.

There is already an On Error Resume Next part.

Ghost in the Machine :)

Anyhow, thanks for the effort.

Regards,

NoviceVBA

"Jacob Skaria" wrote:

Are you sure VLOOKUP() is getting a match..If there is no match this will
return error.

Application.WorkSheetFunction.Vlookup()

If this post helps click Yes
---------------
Jacob Skaria


"VBANovice" wrote:

Hello,

I have a code that is looking for a Vlookup. I know that some of the
queries are N/A# and to have On Error Resume Next error handling.
The code is perfectly working in one computer and is generating "1004 run
time error : Unable to get the Vlookup propert of the WorksheetFunction
class error" in another.

I have reloaded the Excel and Repaired, Diagnosed Excel, restored 2-3 days
before from the backup. None yielded any cure.

I work on XP Pro, have both 2003 & 2007 version generate the same fault.
It seems as if On Error Resume is doomed.

Any suggestions or perhaps remedies mostly welcomed and highly appreciated.

Regards, VBA Novice.