Closed Thread
Results 1 to 3 of 3

Help with a vlookup through entire workbook macro

Hybrid View

  1. #1
    Registered User
    Join Date
    05-22-2013
    Location
    Illinois
    MS-Off Ver
    Excel 2007
    Posts
    17

    Help with a vlookup through entire workbook macro

    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!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Help with a vlookup through entire workbook macro

    Duplicate Thread? http://www.excelforum.com/excel-prog...-optional.html
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help with a vlookup through entire workbook macro

    Thanks

    Duplicate thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1