Probably an easy one. I need to modify the following function to allow Excel to search multiple worksheets for a value. Example...below lookup will look in the sheet "Finished Goods Inventory" for a value. This function works perfectly.
I would like to have it look in sheets "Finished Goods Inventory" and "Raw Inventory" both for the same value. Both the sheets mentioned are in the same workbook. I think this is possible, but I am not sure. Thanks in adavance for any help.
Rick
Function DoLookup(ID As String, strDesc As String, curPrice As Currency, lQty As Long, nRow As Long)
'After barcode is scanned do the lookup
Dim nLastRow As Long
'get last row containing data
nLastRow = Sheets("Finished Goods Inventory").Cells(65000, 1).End(xlUp).Row
With Worksheets(1)
Set c = .Range("a2:a" & Format$(nLastRow)).Find(ID, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=True)
If c Is Nothing Then
DoLookup = False
nRow = 0
Exit Function
Else
nRow = c.Row
Rows(nRow).Select
strDesc = c.Offset(0, 1).Value
curPrice = c.Offset(0, 2).Value
lQty = c.Offset(0, 3).Value
DoLookup = True
End If
End With
End Function
I would like to have it look in sheets "Finished Goods Inventory" and "Raw Inventory" both for the same value. Both the sheets mentioned are in the same workbook. I think this is possible, but I am not sure. Thanks in adavance for any help.
Rick
Function DoLookup(ID As String, strDesc As String, curPrice As Currency, lQty As Long, nRow As Long)
'After barcode is scanned do the lookup
Dim nLastRow As Long
'get last row containing data
nLastRow = Sheets("Finished Goods Inventory").Cells(65000, 1).End(xlUp).Row
With Worksheets(1)
Set c = .Range("a2:a" & Format$(nLastRow)).Find(ID, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=True)
If c Is Nothing Then
DoLookup = False
nRow = 0
Exit Function
Else
nRow = c.Row
Rows(nRow).Select
strDesc = c.Offset(0, 1).Value
curPrice = c.Offset(0, 2).Value
lQty = c.Offset(0, 3).Value
DoLookup = True
End If
End With
End Function