PC Review


Reply
Thread Tools Rate Thread

Add loop to Vlookup

 
 
=?Utf-8?B?TGVz?=
Guest
Posts: n/a
 
      19th Apr 2007
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

--
Les
 
Reply With Quote
 
 
 
 
Allen Lance
Guest
Posts: n/a
 
      19th Apr 2007
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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: vlookup loop help Heera Chavan Microsoft Excel Programming 0 6th Apr 2010 05:13 PM
Vlookup Loop James Microsoft Excel Programming 1 13th Jan 2010 02:23 AM
using vlookup in a loop chrismv48 Microsoft Excel Programming 2 19th Sep 2008 09:15 PM
Vlookup and print loop MM User Microsoft Excel Programming 7 14th Aug 2008 04:29 PM
loop and vlookup =?Utf-8?B?TmV3VG9WQg==?= Microsoft Excel Programming 5 26th Jul 2007 02:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:56 PM.