View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Living the Dream Living the Dream is offline
external usenet poster
 
Posts: 151
Default VLookup using VB

Hi all

Was hoping someone could correct my seemingly non-working attempt at the
subject matter.

Dim sMain As Worksheet, sExtra As Worksheet
Dim myDMrng As Range, myDErng As Range
Dim c As Range
Dim Col As Integer

Set sMain = Sheets("Main")
Set sExtra = Sheets("Extra")

Set myDMrng = sMain.Range("$K$2:$K$250")
Set myDErng = sExtra.Range("$A$2:$B$50")
Col = 2

For Each c In myDMrng
If c.Offset(0, -1) < "" Then
With c
.Value = WorksheetFunction.VLookup(c.Offset(0,
-1).Value, myDErng, Col, 0)
End With
End If
Next c

I was inserting RC.formula with the Vlookup, then doing a copy/paste
throughout the balance of the range but it takes way too long hence why
I am trying something different to speed things up.

TIA
Mick.