Loops

S

Snow

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??
 
F

Frank Kabel

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
 
Top