Hi everyone,
I'm new here and am hoping you can help as I've been over and over this and cannot figure out why it's not working. I'm am VERY NEW to VBA so it could be as simple as placing the code in the wrong module or not "linking" it to the worksheet properly which is why I'm reaching out to all you experts!
I have a worksheet that I enter a part number in and then I would like that worksheet to lookup that number in another worksheet that contains about 70 tabs for a descpription. To that end I was able to find this code but, when I enter this formula: =vlookallbooks("AI039301",A:C,2,FALSE) I get a #NAME? error; I've tried entering the name of the other worksheet too but still no luck.
I would appreciate any help you can provide!! Thanks.
Here's the code I'm using:
[pre]
[/pre]
I'm new here and am hoping you can help as I've been over and over this and cannot figure out why it's not working. I'm am VERY NEW to VBA so it could be as simple as placing the code in the wrong module or not "linking" it to the worksheet properly which is why I'm reaching out to all you experts!
I have a worksheet that I enter a part number in and then I would like that worksheet to lookup that number in another worksheet that contains about 70 tabs for a descpription. To that end I was able to find this code but, when I enter this formula: =vlookallbooks("AI039301",A:C,2,FALSE) I get a #NAME? error; I've tried entering the name of the other worksheet too but still no luck.
I would appreciate any help you can provide!! Thanks.
Here's the code I'm using:
[pre]
Code:
Function vlookallbooks(Look_Value As Variant, Tble_Array As Range, Col_num As Integer, Range_look As Boolean, ParamArray wkbks())
'Use VLOOKUP to Look across ALL Worksheets and stops at the first match found.
Dim wSheet As Worksheet
Dim vFound
On Error Resume Next
found = False
For Each wkbk In Active.wkbks
Set Searchbook = Workbooks(wkbk)
For Each wSheet In ActiveWorkbook.Worksheets
With wSheet
Set Tble_Array = .Range(Tble_Array.Address)
vFound = WorksheetFunction.VLookup Look_Value, Tble_Array, Col_num, Range_look)
End With
If Not IsEmpty(vFound) Then
found = True
Exit For
End If
Next wSheet
If found = True Then Exit For
Next wkbk
Set Tble_Array = Nothing
vlookallbooks = vFound
End Function