Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello guru's,
I need some help to figure out a solution to my issue. I have a list on sheet 2 (named ProjectList) and on sheet 1, a column that needs to be filled with the result from sheet 2 that is held in the third column. The list contains: primary, alias and type. I am trying to use the Vlookup for the type, but the value that i am searching for could be either in the primary or alias columns.... I can loop though the columns in the list to get the right match, however the problem is i don't know if it will be in the primary or alias column, so the vlookup will only work for the values that match in the 1st column (primary). the question is, how do i search one column and then the next, but add the vlookup to use both columns... I have also tried naming the 2nd and third columns in the list to AliasList, then using ' Cells(x, 6).Formula = "=VLOOKUP(" & Cells(x, 4).Address & _ ' ", AliasList,2,True)" but how can i use the loop or if's to check both lists??? I hope that i have explained this correctly. Thanks for any insight someone can provide. As always, thank you very much, and your help is greatly appreciated. Keri~ Code i have now: Dim x As Integer Dim FinalRow As Long Dim w As Worksheet Dim rw As Long Dim r, s FinalRow = Cells(Rows.Count, 4).End(xlUp).Row rw = Sheets("Project").Cells(65500, 1).End(xlUp).Row Set w = Sheets("Project") 'this is where the list resides For x = 2 To FinalRow s = Cells(x, 4).Value If Cells(x, 6).Value = "" Then For Each r In w.Range("A2:B" & rw) If r.Value = s Then Cells(x, 6).Formula = "=VLOOKUP(" & Cells(x, 4).Address & _ ", ProjectList,3,True)" Exit For End If Next r End If Next x |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
vlookup for 4 different ranges | Excel Discussion (Misc queries) | |||
For Loops and Named ranges | Excel Programming | |||
Vlookup macro that returns data from worksheet, then Loops | Excel Programming | |||
Vlookup macro that returns data from worksheet, then Loops | Excel Programming | |||
Ranges / Loops | Excel Programming |