Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default vlookup loop help

Try this.
Sub asddfa()

Dim myRange As Range
Dim lastRow As Integer
Dim c As Variant

lastRow = ActiveSheet.Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set myRange = ActiveSheet.Range("B2:B" & lastRow)


For Each c In myRange
c.Value = Application.VLookup(c.Offset(0, -1).Value,
Sheets("Sheet2").Range("$A$2:$D$2907"), 4, False)
Next


End Sub


"< AVG Joe" wrote:

I need to use the value from colum a on sheet 1 and populate column b on
sheet 1 from a vlookup of the value from sheet 2. I realize I could just
"copy down" but both sheets will have many and variable number of rows. Also,
would prefer to set column b to the "value" of the vloookup and not the
formula itself. I sure appreciate the help!
Here is my basic layout:
Sheet 1:
PTN GTS
123
345

Sheet 2:
PTN GTS
123 XYZ
456 ABC

CODE:
Dim myRange As Range
Dim lastRow As Integer
Dim c As Variant

lastRow = ActiveSheet.Cells(Cells.Rows.Count, "I").End(xlUp).Row
Set myRange = ActiveSheet.Range("I2:I" & lastRow) 'Change to suit

For Each c In myRange
myRange.Value = Application.VLookup("H2",
"Sheet2!$A$2:Sheet2!$D$2907", 4, False)
Next

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
Vlookup Loop James[_47_] Excel Programming 1 January 13th 10 02:23 AM
using vlookup in a loop chrismv48 Excel Programming 2 September 19th 08 09:15 PM
Add loop to Vlookup Les Excel Programming 1 April 19th 07 04:05 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


All times are GMT +1. The time now is 11:02 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"