+ Reply to Thread
Results 1 to 10 of 10

Vlookup on multiple sheets

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2013
    Posts
    167

    Vlookup on multiple sheets

    Hello, I am Abdul Rouf Roofi, Document Controller from Descon Engineering Limited Pakistan. I came to this forum through google and i would appreciate if someone help me to use Vlookup on multiple sheets. I am attaching my worksheet here for kind perusal.

    Thanks
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Vlookup on multiple sheets

    Hi and welcome to the forum

    Change your formula to this...
    =VLOOKUP(G$5,INDIRECT(LEFT(G5,2)&"!D2:Q10"),2,0)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    06-07-2013
    Location
    Nairobi
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Vlookup on multiple sheets

    Great formula. Mine are loooong ones.

  4. #4
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2013
    Posts
    167

    Re: Vlookup on multiple sheets

    Dear Savannaexcel,
    Thank you very much. your formulae worked.but only for 7 sheets
    my 50% problem solved.
    Last edited by roofi; 06-07-2013 at 07:35 AM.
    Abdul Rouf Roofi

  5. #5
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2013
    Posts
    167

    Re: Vlookup on multiple sheets

    Dear FDibbins,
    yours is Great it really works............Thanks a lot, and thanks for explaining syntax.
    100% solved
    Last edited by roofi; 06-10-2013 at 02:39 AM.

  6. #6
    Registered User
    Join Date
    06-07-2013
    Location
    Nairobi
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Vlookup on multiple sheets

    Enter the following formulas in each of the three cells:

    =+IFERROR(VLOOKUP(G$5,RR!D:Q,2,0),IFERROR(VLOOKUP(G$5,PF!D:Q,2,0),IFERROR(VLOOKUP(G$5,SA!D:Q,2,0),IFERROR(VLOOKUP(G$5,SI!D:Q,2,0),IFERROR(VLOOKUP(G$5,MR!D:Q,2,0),IFERROR(VLOOKUP(G$5,FB!D:Q,2,0),"Could Not Be Found"
    ))))))


    =+IFERROR(VLOOKUP(G$5,RR!D:Q,3,0),IFERROR(VLOOKUP(G$5,PF!D:Q,3,0),IFERROR(VLOOKUP(G$5,SA!D:Q,3,0),IFERROR(VLOOKUP(G$5,SI!D:Q,3,0),IFERROR(VLOOKUP(G$5,MR!D:Q,3,0),IFERROR(VLOOKUP(G$5,FB!D:Q,3,0),"Could Not Be Found"
    ))))))


    =+IFERROR(VLOOKUP(G$5,RR!D:Q,10,0),IFERROR(VLOOKUP(G$5,PF!D:Q,10,0),IFERROR(VLOOKUP(G$5,SA!D:Q,10,0),IFERROR(VLOOKUP(G$5,SI!D:Q,10,0),IFERROR(VLOOKUP(G$5,MR!D:Q,10,0),IFERROR(VLOOKUP(G$5,FB!D:Q,10,0),"Could Not Be Found"
    ))))))

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Vlookup on multiple sheets

    Thanks. The indirect() function is ideal for this sort of thing

  8. #8
    Registered User
    Join Date
    06-07-2013
    Location
    Nairobi
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Vlookup on multiple sheets

    And what would be the best alternative for an indirect function between two workbooks? I have been using the code below but it is slow.

    Function pull(xref As String) As Variant
    'inspired by Bob Phillips and Laurent Longre
    'but written by Harlan Grove
    '-----------------------------------------------------------------
    'Copyright (c) 2003 Harlan Grove.
    '
    'This code is free software; you can redistribute it and/or modify
    'it under the terms of the GNU General Public License as published
    'by the Free Software Foundation; either version 2 of the License,
    'or (at your option) any later version.
    '-----------------------------------------------------------------
    Dim xlapp As Object, xlwb As Workbook
    Dim b As String, r As Range, c As Range, n As Long
    
    pull = Evaluate(xref)
    
    If CStr(pull) = CStr(CVErr(xlErrRef)) Then
    On Error GoTo CleanUp 'immediate clean-up at this point
    
    Set xlapp = CreateObject("Excel.Application")
    Set xlwb = xlapp.Workbooks.Add 'needed by .ExecuteExcel4Macro
    
    On Error Resume Next 'now clean-up can wait
    
    n = InStr(InStr(1, xref, "]") + 1, xref, "!")
    b = Mid(xref, 1, n)
    
    Set r = xlwb.Sheets(1).Range(Mid(xref, n + 1))
    
    If r Is Nothing Then
    pull = xlapp.ExecuteExcel4Macro(xref)
    Else
    For Each c In r
    c.Value = xlapp.ExecuteExcel4Macro(b & c.Address(1, 1, xlR1C1))
    Next c
    
    pull = r.Value
    End If
    
    CleanUp:
    If Not xlwb Is Nothing Then xlwb.Close 0
    If Not xlapp Is Nothing Then xlapp.Quit
    Set xlapp = Nothing
    End If
    End Function
    Last edited by vlady; 06-10-2013 at 02:46 AM.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Vlookup on multiple sheets

    savanna, please use code tags when posting VBA (see my note 1 below).

    Also, indirect() doesnt work between workbooks/files unless bot are open, you need an add-in for that (more_func i think its called)

    roofi, the indirect() function is a means of taking text, and converting into something that excel can use as a range. So...
    =VLOOKUP(G$5,INDIRECT(LEFT(G5,2)&"!D2:Q10"),2,0)
    is taking the left 2 characters of the contents of G5 (FB or MR etc), and then combing that with your range D2:Q10 to give you the sheetname and cell range FB!D2:Q10. You can add as many sheets as you want, as long as you keep to 2 characters for the name. If you want to use more, then you can change the
    LEFT(G5,2)
    to LEFT(G5,search("=",G5,1)-1)
    That will allow for more than 2 characters

  10. #10
    Forum Contributor
    Join Date
    06-07-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2013
    Posts
    167

    Re: Vlookup on multiple sheets

    Dear FDibbins,
    yours is Great it really works............Thanks a lot, and thanks for explaining syntax.
    100% solved

+ Reply to 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