View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
sylink sylink is offline
external usenet poster
 
Posts: 30
Default Help on Vlookup for Undetermined Range

Am new on macros and need assistance to adjust the macro below for
undetermined ranges

Dim rng As Range
Dim i As Integer

With Worksheets("sheet1")
Set rng = .Range("a2:b8")
End With

For i = 1 To 7
With Worksheets("sheet2") 'assuming the data you want goes to column b
and
'the lookup value is in Column A'
..Cells(1 + i, 2) = Application.WorksheetFunction.VLookup(.Cells(1 + i,
1), rng, 2, 1)
End With

Next i