Add loop to Vlookup

G

Guest

Hi all, i have got the following code that i need to loop with can somebody
please show me how to alter the code....
It works great except i need it to loop down all numbers in column A which
will be variable in length


Sub VLUp()
Dim LookUpTable As Range, LookUpCell As Range
Dim res As String, myRange As Range

Set LookUpTable =
Workbooks("PU0907LCS.xls").Worksheets("LCS").Range("LCS")
Set LookUpCell = Workbooks("90IH0709.xls").Worksheets("KTL").Range("A10")

res = Application.VLookup(LookUpCell.Value, LookUpTable, 7, False)
ActiveCell = res
res = Application.VLookup(LookUpCell.Value, LookUpTable, 2, False)
ActiveCell.Offset(0, 2) = res
res = Application.VLookup(LookUpCell.Value, LookUpTable, 8, False)
ActiveCell.Offset(0, 3) = res


End Sub
 
A

Allen Lance

Les,

There's a few different ways to loop through your active cells.

Here's one simple way of doing that.....

Dim MyRow as long

For MyRow = 1 to Range("A65536").End(xlup).Row

'Put your code in here
'use MyRow as your Row identifier
' For Example Cells(MyRow,1).Value = "Column A of Row MyRow"

Next MyRow

I hope this points you in the right direction.

Allen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top