+ Reply to Thread
Results 1 to 11 of 11

Variable Vlookup across workbooks

  1. #1
    Registered User
    Join Date
    03-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    27

    Variable Vlookup across workbooks

    Hi, I have a bunch of workbooks which I am pulling data on to 1 page. I have attached a very simple example of what I'm trying to achieve.

    Where I have Cats and Dogs in Melbourne and Sydney on the 'Total' workbook, the other workbooks have the data I want to take from. However, you'll notice they are on different rows. The data I have is kind of everywhere, but they both have a heading of "Pets". But then the data is on different rows, some where the data is a few rows below the heading.

    How can I get this to look for "Pets" and then vlookup for the cells below it?

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Variable Vlookup across workbooks

    See the attached modified sheet and the VLOOKUP formulas where your ?'s used to be.

    I created two named ranges:
    1. Syd_Pets (Sydney!A5:B6)
    2. Mel_Pets (Melbourne!A9:B11)

    Hope this helps!

    - Moo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Variable Vlookup across workbooks

    Yeah, I thought of that too, but the problem is, when I pull the report again next month, the data may not stay in the same area. So I need it to find the heading in the sheet, and then look at the data in the cell table below.

    I might just need to doctor it each month, but I wont be doing it usually, so I need it to be fool proof.

  4. #4
    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,933

    Re: Variable Vlookup across workbooks

    try this, copied down and across

    =SUMIF(INDIRECT(B$1&"!A:B"),$A2,INDIRECT(B$1&"!B:B"))
    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

  5. #5
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Variable Vlookup across workbooks

    See my attached REVISED worksheet... added two cells as helpers in B6 and C6 of the totals page. Works like a charm.

    - Moo
    Attached Files Attached Files

  6. #6
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Variable Vlookup across workbooks

    Quote Originally Posted by FDibbins View Post
    try this, copied down and across
    =SUMIF(INDIRECT(B$1&"!A:B"),$A2,INDIRECT(B$1&"!B:B"))
    FD - I got the wrong totals when I tried your formula. I think it is adding the totals for Cats and Dogs from ABOVE the 'Pets' section on the Melbourne sheet plus the 'Pets' section, instead of only from the 'Pets' section.

    - Moo

  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,933

    Re: Variable Vlookup across workbooks

    yes it's adding all the dogs and cats, i though thats what the OP wanted. guess we will have to wait til they are online again

  8. #8
    Registered User
    Join Date
    03-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Variable Vlookup across workbooks

    Moo, that works pretty well, thanks. The only issue I could foresee is that the data range goes to cell 100. I was wondering if we could make it go from the first one it finds plus 10 or 15. Just because it might be referencing too much data then. If you saw my actual spread sheet, some of the names occur late with different data. And some of the names don't show up in the first instance.

    The data I have from the supplier is a mess!

    Other than that, it is working great. I'm just worried about the potential issue...

  9. #9
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Variable Vlookup across workbooks

    You could put this in B6:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and this in C6:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This setup will work if the data always falls within 15 rows of the word "Pets". Otherwise, you should probably consider VBA code. You can change the total # of rows being included in the range by reducing or increasing the very last number in each formula (15).

    - Moo

  10. #10
    Registered User
    Join Date
    03-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Variable Vlookup across workbooks

    Excellent! That is perfect for what I need. Thank you very much Moo! You deserve a promotion!

  11. #11
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Variable Vlookup across workbooks

    Quote Originally Posted by cowproduct View Post
    Excellent! That is perfect for what I need. Thank you very much Moo! You deserve a promotion!
    You're welcome! And I hope that includes doubling my paycheck too... Let's see, using Excel to figure my new salary:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I'm rich!

    - Moo

+ 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