View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default macro cut and paste

Looks like that End If should be End Sub.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"hey" wrote in message
...
Below what you gave me last week doesnt work. It doesnt like the last

end if?

Thanks


sub foo()
dim look_rng as range
dim source_rng as range
dim target_rng as range
dim ret_value
with activesheet
set look_rng = .range("A1")
set target_rng = .rnage("B1")
set source_rng = .range("C1:D100")
end with
ret_value=application.vlookup(look_rng,source_rng, 2,0)
if iserror(ret_value) then
ret_value=""
end if
target_rng=ret_value
end if