Я создал базу данных для более быстрого поиска инвентаря.Но теперь у меня возникают проблемы при попытке выяснить, как показать инвентарь из другой строки, если идентификатор в первом столбце совпадает, но идентификатор во втором столбце - это то, что мне нужно искать.
Dim BlendRow As Integer
Dim srchRow As Range
Dim LPNRow As Integer
Dim nxtRow As Long
If Application.WorksheetFunction.CountIf(Sheets("Location list").Range("Dyn_Blend_ID"), Blend_id) > 0 _
And Application.WorksheetFunction.CountIf(Sheets("Location list").Range("Dyn_LPN_ID"), LPN_id) > 0 Then
GoTo Start
ElseIf Locate_Lot.Blend_id = "" Then
MsgBox "You did not enter a valid Lot ID", 0, "Check"
Exit Sub
ElseIf Locate_Lot.LPN_id = "" Then
MsgBox "Your LPN is not correct!", 0, "Check LPN"
Exit Sub
End If
Start:
'This is where I'm having issues. If the first column has 2 or more of the same ID, I need it sort
'to show through them to find the correct ID in the second column and put
'the information from the second or third, etc. in the information box that comes up.
' Column A has a REF #, The user puts information they want to look for
'in the input boxes. In column B is the value of the first input box,
'and Column E has the value of the second input box. BUT, if there are
'two of the same IDs in column B, I need it to sort through those to find
'and display the information matched to the second input box from column E.
if not iserror(Application.match(Locate_Lot.LPN_ID, sheets("Location list").range("Dyn_LPN_ID"), 0)) then
BlendRow = (Application.match(Locate_Lot.LPN_ID, sheets("Location list").range("Dyn_LPN_ID"), 0)
end if
'The above is now working, but only matches on the second column,
'but I need it to match on both columns from both input boxes of
'this Locate_Lot userform.
' nxtRow = Sheets("Location list").Cells(Rows.Count, 1).End(xlUp).Row
' For Each srchRow In Sheets("Location list").Range("Dyn_Blend_ID" & nxtRow)
' If (srchRow = ("Locate_Lot.Blend_id")) And srchRow.Offset(0, 4).Value = '("Locate_Lot.LPN_id") Then
' BlendRow = Application.WorksheetFunction.Match(Locate_Lot.LPN_id, Sheets'("Location list").Range("Dyn_LPN_ID"), 0)
' End If
' Next srchRow
Sheets("Engine").Range("B5").Value = BlendRow
Sheets("Engine").Range("B6").Value = LPNRow
Unload Print_inventory
'''Begin retrieveing data from the Location List'''
Location_Clear.Blend_id = Sheets("Location List").Range("Data_Start").Offset(BlendRow, 1).Value
Location_Clear.Item_id = Sheets("Location List").Range("Data_Start").Offset(BlendRow, 2).Value
Location_Clear.BG_id = Sheets("Location List").Range("Data_Start").Offset(BlendRow, 3).Value
Location_Clear.LPN_id = Sheets("Location List").Range("Data_Start").Offset(BlendRow, 4).Value
Location_Clear.Tower_id = Sheets("Location List").Range("Data_Start").Offset(BlendRow, 5).Value
Location_Clear.Shelf_id = Sheets("Location List").Range("Data_Start").Offset(BlendRow, 6).Value
Location_Clear.Show
Рис столбцов с введенными данными.Необходимо сопоставить столбцы B и E и отсортировать по E, возвращая данные этой строки.