Macro help

  • Thread starter Thread starter shternm
  • Start date Start date
S

shternm

I can't figure out how to set up VLOOKUP formula with 2 variabl
elements.
After the intial formula runs in the specified cell, I want 2 element
changed: the location of the result and the lookup value.
In the case below that would be B1 and A2.

Range("B1") = Application.WorksheetFunction.VLookup(Range("A2"
Range("data"), 2, False)

I've tried setting it up like this:
Dim i, k As Integer
For i = 1 To 2
For k = 1 To 2
Range("B" & k) = Application.WorksheetFunction.VLookup(Range("a"
i), Range("data"), 2, False)
Next
Next

But then I get it to run 4 times returning the same result in 2 cells.
Please help
 
shternm,

From your code it seems that only cells B1 and B2 are updated (twice).
Similarly you are looking up the values in A1 and A2 twice.

Could you please give a bit more deatil on what you intended to do
 
Back
Top