instanceoftime
Board Regular
- Joined
- Mar 23, 2011
- Messages
- 103
workbook "invoice" column A has item numbers. workbook "price" column A has item numbers and column H price (should have price)
if H does contain the price then place that info in H "invoice" ... then continuing the fill-in process until last row
if the H doesn't contain a price, continue same search of same item# until the last row. (and left blank if no price was found)
"price" has multiple instances of the same item#. Just need to find the first one that has price in column H
there are no blanks in column A at all
"price has 50,000 rows
I've used the following search method in a different workbook but unsure how to adapt it.
if H does contain the price then place that info in H "invoice" ... then continuing the fill-in process until last row
if the H doesn't contain a price, continue same search of same item# until the last row. (and left blank if no price was found)
"price" has multiple instances of the same item#. Just need to find the first one that has price in column H
there are no blanks in column A at all
"price has 50,000 rows
I've used the following search method in a different workbook but unsure how to adapt it.
Code:
[COLOR=#ff0000]'This is old code that searched for item# input by user on the form, retrieves B, C, & D and puts it on the form' (I'm not using a form or anything for this new project .. just need to place price(H) into invoice(H)
'This is old code that I could adapt? An array that pulls three columns of numbers but I only need column (8)[/COLOR]
Private Sub cmdSearch_Click()
Dim Response As Long
Dim NotFound As Integer
Dim arr As Variant
Dim I As Long
Dim str1 As String, str2 As String, str3 As String
NotFound = 0
ActiveWorkbook.Sheets("Items").Activate
Response = Val("0" & Replace(txtItemNumber.Text, "-", "")) [COLOR=#ff0000]'with this code the user inputs item#[/COLOR]
ItemNumber = Response
If Response <> False Then
With ActiveSheet
arr = .Range("A2:D" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With
For I = 1 To UBound(arr)
If arr(I, 1) = Response Then
str1 = IIf(str1 = "", arr(I, 6), str1 & "|" & arr(I, 6))
str2 = IIf(str2 = "", arr(I, 7), str2 & "|" & arr(I, 7))
str3 = IIf(str3 = "", arr(I, 8), str3 & "|" & arr(I, 8))
End If
Next
If str1 = "" Then
MsgBox "Item Number Not Found!", vbExclamation
NotFound = 1
txtItemNumber.Text = ""
txtItemNumber.SetFocus
Else
lbxDescription.List = Split(str1, "|") [COLOR=#ff0000]'fills in user form[/COLOR]
lbxCost.List = Split(str2, "|")
ListBox3.List = Split(str3, "|")
lbxCost.ListIndex = 0
End If
End If
End Sub
Last edited: