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: 4,339
Default Vlookup Question

Hi,

Try this (on test data!).

HTH

Sub matchABC()

Dim mArr() As String
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim lastrow As Long, r As Long
Dim outrng As Range
Dim FindMatch As String

Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
Set ws3 = Worksheets("Sheet3")

Set outrng = ws3.Range("a2")

ws2.Activate
With ws2
lastrow = .Cells(Rows.Count, "B").End(xlUp).Row
ReDim mArr(1 To lastrow - 1)
For r = 2 To lastrow ' Store part number from sheet2
mArr(r - 1) = .Cells(r, 2)
Next r

End With

ws1.Activate
With ws1
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
For r = 2 To lastrow
FindMatch = .Cells(r, 1)
res = Application.Match(FindMatch, mArr, 0) ' Look for match in
sheet2 list
If Not IsError(res) Then
.Cells(r, 1).Copy outrng ' Part # from sheet1
ws2.Cells(res + 1, 2).Resize(1, 5).Copy outrng.Offset(0, 1) '
Copy B-F to sheet3 from sheet2
Set outrng = outrng.Offset(1, 0)
End If
Next r
End With
End Sub



"DA@PD" wrote:

Okay, I've asked this question before... but I'm still unclear on the solution.

I have a list of part numbers in Column A on Sheet1, I would like to be able
to do an exact match Vlookup with Column B on Sheet 2.

When there is a match, I would like to have the matches generated in column
A of Sheet 3, but in addition to this, if there is a match, I would like the
columns B,C,D,E & F from sheet 2 also populate along with the matching part
number on Sheet 3. When I asked this question before, I was told to just use
Vlookup for the additional data, I have the part numbers only in Sheet 1, no
other columns worth of data to match against Sheet 2. Can anyone Help??

Thanks!

 
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 Question OverMyHead Excel Discussion (Misc queries) 3 November 14th 09 11:18 PM
vlookup question SteveDB1 Excel Worksheet Functions 2 September 27th 07 07:09 PM
Vlookup question aka_krakur Excel Discussion (Misc queries) 2 July 29th 06 12:17 AM
vlookup question brutus Excel Programming 4 August 9th 05 05:20 AM
VLOOKUP Question Haldun Alay[_2_] Excel Programming 2 October 10th 03 11:30 AM


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