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

Bernie, thanks so much for the reply, i have this...
Dim x As Integer
Dim FinalRow As Long
FinalRow = Cells(Rows.Count, 4).End(xlUp).Row
For x = 2 To FinalRow

If Cells(x, 6).Value = "" Then
Cells(x, 6).Formula = "=IF(ISERROR(VLOOKUP(" & Cells(x,
4).Address & _
",ProjectList,3,False)),VLOOKUP(" & Cells(x, 4).Address &
_
",AliasList,2,False),VLOOKUP(" & Cells(x, 4).Address & _
",ProjectList,3,False))"
End If

Next x

However, i am getting #N/A in some of the fields and I know for a fact
that there are matches in the vlookup ranges..
It seems like this is such the better solution, but i was also working
on this one too... out of pieces of code i found...

I am using this and it works... but would like the shorter solution,
like yours...
'////////////////////////////////////////////////////////////////
Dim x, FinalRow, rw As Long
Dim w As Worksheet
Dim s, r
Dim rng As Range
FinalRow = Cells(Rows.Count, 4).End(xlUp).Row
rw = Sheets("Project").Cells(65500, 1).End(xlUp).Row
Set w = Sheets("Project")
Dim MyColumn As String, Here As String
Set rng = w.Range("A2:B" & rw)
For x = 2 To FinalRow
Cells(x, 6).Select
s = Cells(x, 4).Value
If Cells(x, 6).Value = "" Then
For Each r In rng
If r.Value = s Then
'Cells(x, 6).Value = r.Value
Cells(x, 7).Value = r.Address
Cells(x, 6).Formula = "=VLOOKUP(" & Cells(x, 4).Address &
_
", ProjectList,3,True)"
Here = r.Address
MyColumn = Mid(Here, InStr(Here, "$") + 1, InStr(2, Here,
"$") - 2)
If MyColumn = "B" Then
'MsgBox "my column = B"
Cells(x, 4).Clear
Cells(x, 4).Value = r.Offset(0, -1).Value
Cells(x, 6).Formula = "=VLOOKUP(" & Cells(x, 4).Address
& _
", ProjectList,3,True)"
End If
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 05:47 AM.

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"