I'm trying to use a macro that will search the entire workbook. Here is the macro I'm using:
Function VLOOKUPWORKBK(Look_Value As Variant, Tble_Array As Range, Col_num As Integer, Optional Range_look As Boolean)
'Vlookup function that will search all worksheets in the workbook - however, the data table that is being searched must be in the same
'location on every worksheet.
Dim wSheet As Worksheet
Dim vFound
On Error Resume Next
For Each wSheet In ActiveWorkbook.Worksheets
With wSheet
Set Tble_Array = .Range(wSheet.Name & "!" & Tble_Array.Address)
vFound = Application.WorksheetFunction.VLookup(Look_Value, Tble_Array, Col_num, Range_look)
End With
If Not IsEmpty(vFound) Then Exit For
Next wSheet
VLOOKUPWORKBK = vFound
End Function
When I call the function I use this: =VLOOKUPWORKBK(A3,$A$3:$A$103, 4, 0) but it just returns a zero everytime.
I have attached the workbook. You will find the function on the "materials list" sheet in cell d3.
Any help would be appreciated!
Bookmarks