+ Reply to Thread
Results 1 to 18 of 18

Lookup function for multiple worksheets

  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    nottingham
    MS-Off Ver
    Excel 2003
    Posts
    2

    Lookup function for multiple worksheets

    Apologies if this is in the wrong forum...

    But I require some assistance, I have been trying for the past several hours for a solution, but I seem to be missing something.

    I am trying to create a VLOOKUP function which searches multiple sheets.



    The VLOOKUP for the individual sheet is (this works pefectly):

    =VLOOKUP(A479,'iWc 23-05-11'!$B$3:$N$30,13,FALSE)




    However, I have 52 different Sheet names off which I want to search from. The layout/cells are exactly the same on each sheet, however the reference is unique.



    I have searched the net and keep coming up with this function:

    =VLOOKUP(A479,INDIRECT("'"&INDEX(A1:A52,MATCH(TRUE,COUNTIF(INDIRECT("'"&A1:A52&"'!B3:N30"),A479)>0,0))&"'! B3:N30"),13,0)



    Basically, putting all the sheet names in a seperate sheet called 'INDEX'.

    The above function does not return a value and seems to cause an error.

    I hope I have explained everything clearly as to what im trying to acheive, Im hoping its something simple which I have missed.

    The 52 sheets are weekly sheets for the year.

    Your help would be truly grateful.

    Regards

    Matt

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets (Help)

    that is an array formula and needs to be confirmed with ctrl+shift+enter so { } will appear around it
    {=VLOOKUP(A479,INDIRECT("'"&INDEX(A1:A52,MATCH(TRUE,COUNTIF(INDIRECT("'"&A1:A52&"'!B3:N30"),A479)>0,0 ))&"'! B3:N30"),13,0)}
    see link in my signature
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    03-10-2010
    Location
    nottingham
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Lookup function for multiple worksheets (Help)

    Thanks for you response, appreciated,

    Would you say this is the best method for what i after or is there another way without having to press control, shift and enter each time?

    regards
    Matt

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets

    once its entered it stays like that, you can put a new value in a479 and it will find it

  5. #5
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    This looks like just the answer I am searching for. I have copied the formula and created an additional sheet called index with a list of the spreedsheet names but it is coming up as a #REF error. Can you see what I am missing in the attached test file ?

    Cheers
    Rhys
    Attached Files Attached Files

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets

    please don't post in someone else's thread, start a new one linking to here if needed
    but to clarify things if someone else also has the same problem
    1.it should be
    =VLOOKUP(A1,INDIRECT("'"&INDEX(INDEX!A$1:A$52,MATCH(TRUE,COUNTIF(INDIRECT("'"&INDEX!A$1:A$52&"'!a1:e30"),A1)>0, 0 ))&"'!a1:e30"),5,0)
    2.beware when copying sometimes extra spaces appear when copied your example had a space
    here
    A1)>0, 0 ))&"'! a1:e30")
    between ! and a1

    3.also naming your sheet index confuses matters! you needed to include the sheet name in
    INDEX!A$1:A$52,
    4. it also helps if you spell burritos the same on both sheets or vlookup wont find a match
    Last edited by martindwilson; 05-30-2011 at 08:10 AM.

  7. #7
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    sure, i didnt realise

  8. #8
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    I only saw the first line of your post in my email notification, didnt realise you had answered my question. Thank you for that. Still a bit confused re how to include the sheet names in the index sheet (have renamed it to' list' as i see your point re confusion). I assume there is a syntax to tell excel that you are referring to a sheet when you write the name in as all I had was the name but excel wouldn't know I was referring to a sheet and would just see it as text but I'm almost there now

    Thanks a lot
    Rhys

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets

    =VLOOKUP(A1,INDIRECT("'"&INDEX('sheet name'!A$1:A$52,MATCH(TRUE,COUNTIF(INDIRECT("'"&'sheet name'!A$1:A$52&"'!a1:e30"),A1)>0, 0 ))&"'!a1:e30"),5,0)
    where "sheet name" is sheet with list of sheets

  10. #10
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    At the risk of dragging on in someone else post I am very appreciative of your help but am now getting both #ref and #n/a responses to the same formula code. I just can't see what I'm missing in the attached and why it won't pick up the numbers in column E in each of the sheets named Week 1,2 etc and pop them in the first sheet. I'm sure it is something quite simple. Can you point me in the right direction ?

    cheers
    rhys
    Attached Files Attached Files

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets

    you haven't array entered it see post #2

  12. #12
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    I did try on the individual formula cells but nothing happened. Then looking at the example referred to in your signature I tried it across the B1:B3 in Sheet1 and got it to put the braces on but still #ref and #na errors. then I tried it again across the three rows in column B using the following variation of the formula

    =VLOOKUP(A1:A3,INDIRECT("'"&INDEX(list!A$1:A$54,MATCH(TRUE,COUNTIF(INDIRECT("'"&list!A$1:A$54&"'!a1:e30"),A1:A3)>0,0))&"'!a1:e30"),5,0)

    ie changing the lookup from the cell in the same row to the range and it did put the braces on but still the errors. Very confused !

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets

    heres yours
    VLOOKUP(A1:A3 is wrong you can only look at one cell at a time
    VLOOKUP(A1,
    vlookup whats in cell a1 and return values from the other sheets
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    That is very helpful, thanks. Interesting point I have just discovered and part of the reason I have been struggling with this is that the sheet you have fixed works fine on my work pc with excel 2010 but at home I'm using 2007 and instead of showing the solution the formulas in the very same workbook are #ref errors (saving as excel workbook doesnt help). Strange that the compatibility issue is so significant. Should I be upgrading to 2010 at home ? If I hadn't been playing with it at work I would never have realised that the version is causing such a problem

  15. #15
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets

    shouldn't be i did that workbook in excel 97

  16. #16
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    Thanks so much for your help, I have got it working and your advice is going to save me so much time. I really appreciate it. One last question, I don't suppose there is any way to create a wildcard for the list of sheets. ie some of the sheets will be automatically created with a constant intro and then a number that changes with each instance. eg sample1222, sample1287, sample1322 etc, etc. Is there anyway to create a single entry that will cover any sheets that start with sample regardless of the numbers that follow ?
    Cheers
    Rhys

  17. #17
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup function for multiple worksheets

    i don't really know! i just started by fixing the op's function.but i doubt it using this method as essentially you'd have all sheets with the same name

  18. #18
    Registered User
    Join Date
    05-02-2011
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Lookup function for multiple worksheets

    I did think I might be pushing it on that request. Thanks again for your help getting this set up, it is such a relief not to have to manually enter all the information. Re the wildcard possibility I'll start a new thread, not hopeful but you never know

    Cheers
    Rhys

+ 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