lookup part number in a vertical list and return the most recent .

G

Guest

I need to lookup a part number in a "shipment Log" worksheet. It is laid out
with the following column headers: "Part Number" "Aug 1" "Aug 2" "Aug 3"
etc....
If a part has been shipped, there will be a value under the appropriate date
column. This value will be the quantity shipped.
I am trying to find the most recent shipment date and return that date into
a cell in another spreadsheet. Does anyone have any suggestions?
 
Z

Zone

I'll give this a shot. Are the column headings for the shipping date
formatted as text (like Aug 2, Aug 3) or dates (like 2-Aug, 3-Aug) or what?
Also, is the sheet with the date columns laid out with the part number in
column A, first date in column B, second date in column C, and so on to Aug
31, with no blanks in-between? James
 
G

Guest

The column headings are: general format for Column "A" titled "Buyer-Part-#"
with date titles in the next columns in the format of "8/1/2007"....8/31/2007"
There are no blank columns in between the dates.
Thanks.James
 
Z

Zone

James, this is probably not the most elegant way to do this, but it should
work okay.
Copy this code and paste it into a standard module.
Assumptions:
1. The ship dates are in Sheet2 (change as needed)
2. BuyerPart# is in column A of Sheet2, and ship dates begin in column B
and continue until the end of the month with no spaces between the
BuyerPart# and Aug 31.
3. Row 1 of Sheet2 is a heading row, with a non-empty heading cell for the
BuyerPart# and for each day.

If the part numbers for which you want to get the ship date start in row 2
of column A on the sheet on which you want to get the ship dates, put this
in B2 and drag down as far as needed:
=getship(A2)

Let me know if this works and if you have any questions. Cheers, James

Function GetShip(targ)
Dim RtCol As Integer, shipCol As Integer, shipRow As Long, c As Range
GetShip = ""
With Worksheets("Sheet2")
RtCol = .Cells(1, 1).End(xlToRight).Column
Set c = .Columns(1).Find(targ)
If Not c Is Nothing Then
shipRow = c.Row
shipCol = .Cells(c.Row, "a").End(xlToRight).Column
If Not shipCol > RtCol Then GetShip = .Cells(1, shipCol)
End If
End With
End Function
 
Z

Zone

James, I didn't word my assumptions exactly right. What I meant was,
assuming row 1 of the sheet containing the ship dates is a heading row,
there must be at least one empty column to the right of the column
containing Aug 31. Let me know! James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top