Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Add loop to Vlookup

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Add loop to Vlookup

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
using a vlookup command in a for next loop in a macro in excel Amethyst Excel Discussion (Misc queries) 3 March 17th 07 01:30 PM
VLOOKUP loop multiple times Lenny Excel Worksheet Functions 3 September 28th 05 10:31 AM
Need a vb loop for vlookup [email protected] Excel Programming 3 August 25th 05 12:32 PM
Need a vb loop for vlookup [email protected] Excel Programming 2 August 24th 05 04:07 PM
Find & Replace / Loop & Vlookup thom hoyle Excel Programming 5 June 25th 05 12:56 AM


All times are GMT +1. The time now is 10:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"