View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default VLookup in a Macro

Dim res as variant 'could be an error
dim myRng as range
dim myVal as variant 'or long or string or ...

with worksheets("sheet9999")
set myrng = .range("a:e") '5 columns
end with

myVal = worksheets("sheet8888").range("x77").value

res = application.vlookup(myval, myrng, 3, false)

if iserror(res) then
msgbox "Error, not found"
else
msgbox res
end if


Beverly76 wrote:

I am trying to write a macro that duplicates a data evaluation procedure
given to me from someone else. There are several steps requiring VLOOKUPs.
I have been told that I cannot run a VLOOKUP within a macro? Is this a true
statement. If I can do it, how?

--
Sincerely,
Beverly76


--

Dave Peterson