LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Loops, ranges and VLookup

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
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 for 4 different ranges hitesh Excel Discussion (Misc queries) 1 November 12th 07 04:41 PM
For Loops and Named ranges Ronnie Excel Programming 2 December 21st 05 01:20 AM
Vlookup macro that returns data from worksheet, then Loops xlsxlsxls[_3_] Excel Programming 4 October 23rd 04 05:48 PM
Vlookup macro that returns data from worksheet, then Loops xlsxlsxls[_4_] Excel Programming 0 October 23rd 04 05:43 PM
Ranges / Loops fabalicious[_13_] Excel Programming 4 April 21st 04 11:10 AM


All times are GMT +1. The time now is 09:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"