Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Add lookup to for next

Hello. Conceptually I know what to do, but I do not know the proper syntax
to do it. Essentially, I would like to add a Vlookup to the end of the
statement
Cells(i, 1).Value = Cells(i, 1).Value & "|" & Cells(i, j).Value
Where Cells(i, j).Value is the lookup value. So I want to do a vlookup and
find Cells(i, j).Value in Thisworkbook.worksheets("PO
List").Range("D5:H100"), and return column 5. In the code below, I threw in
the vlookup formula at the end of the line, but obviously that doesn't work.
Can you help? Thank you!!


For j = 2 To iLastCol
If Cells(i, j).Value < "" Then
Cells(i, 1).Value = Cells(i, 1).Value & "|" & Cells(i,
j).Value & "=VLOOKUP('[Contractor Master6.xls]HR
DB'!R8C12,'[Contractor Master6.xls]PO Table'!R5C4:R17C8,5,0)"
End If
Next j


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Add lookup to for next

Just use a find and offset similar to this (untested)

Dim rngFound As Range
Dim rngToSearch As Range

Set rngToSearch = ThisWorkbook.Worksheets("PO List").Range("D5:H100")
Set rngFound = rngToSearch.Find(Cells(i, j).Value)

If Not rngFound Is Nothing Then
Set rngFound = rngFound.Offset(0, 5)
rngFound.Select
End If

A little easier to follow in my opinion.
HTH
--
HTH...

Jim Thomlinson


"Steph" wrote:

Hello. Conceptually I know what to do, but I do not know the proper syntax
to do it. Essentially, I would like to add a Vlookup to the end of the
statement
Cells(i, 1).Value = Cells(i, 1).Value & "|" & Cells(i, j).Value
Where Cells(i, j).Value is the lookup value. So I want to do a vlookup and
find Cells(i, j).Value in Thisworkbook.worksheets("PO
List").Range("D5:H100"), and return column 5. In the code below, I threw in
the vlookup formula at the end of the line, but obviously that doesn't work.
Can you help? Thank you!!


For j = 2 To iLastCol
If Cells(i, j).Value < "" Then
Cells(i, 1).Value = Cells(i, 1).Value & "|" & Cells(i,
j).Value & "=VLOOKUP('[Contractor Master6.xls]HR
DB'!R8C12,'[Contractor Master6.xls]PO Table'!R5C4:R17C8,5,0)"
End If
Next j



Reply
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
lookup help. lookup result based on data in 2 columns lcc Excel Worksheet Functions 3 April 6th 10 01:20 PM
LOOKUP FUNCTION? (LOOKUP VALUE BEING A TIME RENERATED FROM A FORMU JCC Excel Discussion (Misc queries) 5 June 26th 09 09:15 PM
Lookup looks to the prior column if zero appears in the lookup col kenbquik Excel Discussion (Misc queries) 2 March 12th 09 03:41 AM
Matrix lookup/mulitple criteria lookup MarkFranklin Excel Discussion (Misc queries) 3 March 31st 08 10:15 AM
Join 2 Lists - Lookup value in 1 list & use result in 2nd lookup JBush Excel Worksheet Functions 3 January 3rd 07 11:14 PM


All times are GMT +1. The time now is 03:58 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"