ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Vlookup with multiple FOR condition (https://www.excelbanter.com/excel-programming/450346-vlookup-multiple-condition.html)

KK[_8_]

Vlookup with multiple FOR condition
 
Hi,

I have below code for vlookup from different sheets. The problem is the inner loop is not exiting after first condition is met. Like I am getting 3 lookups on the same field (JCell) please help

Set JRng = Sheet2.Range("J8:J10")
Set DRng = Sheet3.Range("D23", Sheet3.Range("D23").End(xlDown))

For Each JCell In JRng.Cells
For Each Dcell In DRng.Cells
JCell.Value = Application.WorksheetFunction.VLookup(Dcell, Sheet4.Range("M:N"), 2, False)
Next Dcell
Next JCell

Claus Busch

Vlookup with multiple FOR condition
 
Hi,

Am Wed, 24 Sep 2014 11:32:04 -0700 (PDT) schrieb KK:

I have below code for vlookup from different sheets. The problem is the inner loop is not exiting after first condition is met. Like I am getting 3 lookups on the same field (JCell) please help


try:

Sub Test()
Dim JRng As Range

Set JRng = Sheets("Sheet2").Range("J8:J10")
With JRng
.Formula = "=VLOOKUP(Sheet3!D23,Sheet4!$M$1:$N$1000,2,0)"
.Copy
.PasteSpecial xlPasteValues
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional


All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com