Thread: VLookup in VBA
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default VLookup in VBA

Partly yes, but there is another difference:

Workbooks("PRProc.xls").Names("PRLUrng").RefersToR ange
doesn't require specifying sheet,

Workbooks("PRProc.xls").Sheets("Accounts").Range(" prlurng")
does.

Regards,
Stefi

Dave Peterson ezt *rta:

I don't think it was going through the names collection that solved the
problem. I think it was that Stefi added the .xls in the filename:

Set lookuprng = Workbooks("PRProc.xls").Sheets("Accounts").Range(" a:f")
or
Set lookuprng = Workbooks("PRProc.xls").Sheets("Accounts").Range(" prlurng)



Mike H. wrote:

Referring to the named range this way works perfectly. Thanks!

"Stefi" wrote:

Set lookuprng = Workbooks("PRProc.xls").Names("PRLUrng").RefersToR ange

Regards,
Stefi

âžMike H.❠ezt Ã*rta:

I am trying to use the Vlookup function in VBA and the lookup is to an
external workbook. I get a runtime Error 9 when setting the lookup range:

Set lookuprng = Workbooks("PRProc").Sheets("Accounts").Range("$a$1 :$f$65000")

Actually, my reference is a named range so I'd rather refer to the name
instead, but not sure the syntax for that either:
Set lookuprng = Workbooks("PRProc").Sheets("Accounts").Range("PRLU Rng")



--

Dave Peterson