Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Search and filter mutiple vaules

Hello

I've got a spreadsheet that I need to search on a part number and get it's
price, however there may be multiple part numbers, and the determining
factor would be the revision of that part. such as ...

Part number Rev Price
1234 A 13.00
1787 G 16.50
1234 B 15.00

using the .find method, is there a way to do a search for a part number, and
if multiples are found, get the one that has the latest rev?

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Search and filter mutiple vaules

If you're partnumbers/revision data is sorted nicely, you could use .find and
search from the bottom and use the first one found.

For instance:

Dim wks as worksheet
dim FoundCell as range
dim myStr as string

myStr = "1234"

set wks = worksheets("Somesheetnamehere")

With wks
With .Range("A:A")

Set Foundcell = .Cells.Find(what:=myStr, _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)

end with
end with

if foundcell is nothing then
'...
else
msgbox foundcell.offset(0,2).value
end if

(untested, uncompiled. Watch for typos.)

Starting in the first cell (after:=.cells(1)) and looking up
(searchdirection:=xlprevious) is what makes this work.

If your data isn't sorted -- and you can't sort it, I think you'll have to loop
through your data (.find and .findnext???) and keep track of the latest rev.

ps. Just a tip.

If you're doing an Edit|Find manually, you can shift click on the Find Next
button and it searches in reverse order.




Peter wrote:

Hello

I've got a spreadsheet that I need to search on a part number and get it's
price, however there may be multiple part numbers, and the determining
factor would be the revision of that part. such as ...

Part number Rev Price
1234 A 13.00
1787 G 16.50
1234 B 15.00

using the .find method, is there a way to do a search for a part number, and
if multiples are found, get the one that has the latest rev?

Thanks


--

Dave Peterson
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
Running mutiple excel sheets on mutiple computers Lost Excel Discussion (Misc queries) 3 January 16th 09 12:32 AM
search and filter Jenny Excel Worksheet Functions 5 November 27th 07 03:56 PM
Advance filter search does not filter an exact match cfiiland Excel Programming 1 June 10th 05 12:44 PM
Search Mutiple Excel Sheets. Ben Jimenez Excel Programming 0 August 8th 03 07:13 PM
Search Mutiple WorkSheets Ben Jimenez Excel Programming 5 July 29th 03 09:48 PM


All times are GMT +1. The time now is 07:29 PM.

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

About Us

"It's about Microsoft Excel"