Thread: finding records
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default finding records

use the vlookup worksheet function in the one worksheet to retreive the data
related to the value in column A in the 119 rows.

Assume both worksheets have the same values in column A.

in B2

=if(countif(Data!A:A,$A2)0,Vlookup($A2,Data!$A$2: $M$50001,Column(),False),"")

then drag across to column M (in the example) and down to row 119

since this is programming, in code
Sub GetData()
with Worksheets("Sheet1").Range("B2:M120")
.Formula =
"=Vlookup($A2,Data!$A$2:$M$50001,Column(),Fals e)"
on Error Resume Next
.SpecialCells(xlFormulas,xlErrors).ClearContents
on Error goto 0
.Formula = .Value
end with
End sub

--
Regards,
Tom Ogilvy

"wayne" wrote in message
...
I have one worksheet with about 119 rows of data. I have the data in
column
A that I want to lookup in another worksheet(about 50,000 rows) and when I
find the matching record I want to write out that row of data for the
match.

Thank you for your help.