ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loops (https://www.excelbanter.com/excel-programming/298247-loops.html)

Snow[_2_]

Loops
 
I am attempting to run a loop which takes cell A1 and
tries to locate matching cell (e.g. B35) then replacing
D1 with C35. Any thoughts on how to write this in a
macro in Visual Basic??

Frank Kabel

Loops
 
Hi
why not use a worksheet function. e.g. the following in D1
=VLOOKUP(A1,$B$1:$C$100,2,0)

you can use this also in VBA. Try

dim ret_value
ret_value =
application.worksheetfunction.vlookup(Range("A1"). value,Range("$B$1:$C$
100"),2,0)
Range("D1").value=ret_value


--
Regards
Frank Kabel
Frankfurt, Germany


Snow wrote:
I am attempting to run a loop which takes cell A1 and
tries to locate matching cell (e.g. B35) then replacing
D1 with C35. Any thoughts on how to write this in a
macro in Visual Basic??



Snow[_2_]

Loops
 
Thanks Frank. I will try these and see if I can get
either to work.

Snow

-----Original Message-----
Hi
why not use a worksheet function. e.g. the following in

D1
=VLOOKUP(A1,$B$1:$C$100,2,0)

you can use this also in VBA. Try

dim ret_value
ret_value =
application.worksheetfunction.vlookup(Range

("A1").value,Range("$B$1:$C$
100"),2,0)
Range("D1").value=ret_value


--
Regards
Frank Kabel
Frankfurt, Germany


Snow wrote:
I am attempting to run a loop which takes cell A1 and
tries to locate matching cell (e.g. B35) then replacing
D1 with C35. Any thoughts on how to write this in a
macro in Visual Basic??


.



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

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