ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macros (https://www.excelbanter.com/excel-programming/299836-re-macros.html)

Frank Kabel

macros
 
Hi
why not use VLOOKUP directly?
but if you want try the following:
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

--
Regards
Frank Kabel
Frankfurt, Germany


hey wrote:
I would like to see the writing for a macro that looks up a value in
a table then copies it and pastes it to a certain cell.

Thanks


HEY

macros
 
It doesnt like the last end if?

Frank Kabel

macros
 
Hi
make this
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


Frank Kabel wrote:
Hi
why not use VLOOKUP directly?
but if you want try the following:
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


hey wrote:
I would like to see the writing for a macro that looks up a value in
a table then copies it and pastes it to a certain cell.

Thanks




All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com