D
dbagge
I am using an Excel workbook which uses two sheets:
Bkorder - that holds a list of parts that are on backorder.
Orders - that holds a list of parts that have been ordered.
I have to compare the Part # (Column F) on the Orders sheet to the Supplier
Part # (Column A) of the Bkorder sheet. If there is a match then I pull the
number parts on the past due list (Bkorder - column H) to the Orders sheet
(to column L - back order) so parts can be ordered. The Bkorder sheet is
updated daily and so a new list is created daily.
I have been using the vba function below with no problems until the company
started using part #'s that no longer contained text (example: 2314R123-76
and now we also have 8246537):
Sub SortBkorder()
'
' SortBkorder Macro
' Macro recorded 12/21/2007
'
Dim cnt As Integer, cnum As Integer
cnt = 1
cnum = 6
'Count the number of rows used on Bkorder sheet
Sheets("Bkorder").Select
Range("B2").Select
Do Until ActiveCell.Value = ""
cnt = cnt + 1
ActiveCell.Offset(1, 0).Select
Loop
'Sort Bkorder sheet by Supplier Part
Sheets("Bkorder").Select
Range("A1:M" & cnt).Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'Set focus at A2
Range("A2").Select
'Go back to Orders sheet
Sheets("Orders").Select
'Go to Column L and put in function to get data
Range("L6").Select
Do Until ActiveCell.Offset(0, -6).Value = ""
ActiveCell.Value = "=IF(ISERROR(VLOOKUP(TRIM($F" & cnum &
"),Bkorder!$A$1:$M$" & cnt & ",8,False)),0,(VLOOKUP(TRIM($F" & cnum &
"),Bkorder!$A$1:$M$" & cnt & ",8,False)))"
cnum = cnum + 1
ActiveCell.Offset(1, 0).Select
Loop
'Sort Orders sheet by Maycor Backorder Qty
Range("A5:N" & cnum).Sort Key1:=Range("L6"), Order1:=xlDescending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'Set focus on column L and Row 6
Range("L6").Select
End Sub
All the other part numbers work correctly except the new numbers that show 0
on the Orders sheet but show 10 parts on back order on the Bkorder sheet.
Hope this isn't too confusing.
Bkorder - that holds a list of parts that are on backorder.
Orders - that holds a list of parts that have been ordered.
I have to compare the Part # (Column F) on the Orders sheet to the Supplier
Part # (Column A) of the Bkorder sheet. If there is a match then I pull the
number parts on the past due list (Bkorder - column H) to the Orders sheet
(to column L - back order) so parts can be ordered. The Bkorder sheet is
updated daily and so a new list is created daily.
I have been using the vba function below with no problems until the company
started using part #'s that no longer contained text (example: 2314R123-76
and now we also have 8246537):
Sub SortBkorder()
'
' SortBkorder Macro
' Macro recorded 12/21/2007
'
Dim cnt As Integer, cnum As Integer
cnt = 1
cnum = 6
'Count the number of rows used on Bkorder sheet
Sheets("Bkorder").Select
Range("B2").Select
Do Until ActiveCell.Value = ""
cnt = cnt + 1
ActiveCell.Offset(1, 0).Select
Loop
'Sort Bkorder sheet by Supplier Part
Sheets("Bkorder").Select
Range("A1:M" & cnt).Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'Set focus at A2
Range("A2").Select
'Go back to Orders sheet
Sheets("Orders").Select
'Go to Column L and put in function to get data
Range("L6").Select
Do Until ActiveCell.Offset(0, -6).Value = ""
ActiveCell.Value = "=IF(ISERROR(VLOOKUP(TRIM($F" & cnum &
"),Bkorder!$A$1:$M$" & cnt & ",8,False)),0,(VLOOKUP(TRIM($F" & cnum &
"),Bkorder!$A$1:$M$" & cnt & ",8,False)))"
cnum = cnum + 1
ActiveCell.Offset(1, 0).Select
Loop
'Sort Orders sheet by Maycor Backorder Qty
Range("A5:N" & cnum).Sort Key1:=Range("L6"), Order1:=xlDescending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'Set focus on column L and Row 6
Range("L6").Select
End Sub
All the other part numbers work correctly except the new numbers that show 0
on the Orders sheet but show 10 parts on back order on the Bkorder sheet.
Hope this isn't too confusing.