+ Reply to Thread
Results 1 to 21 of 21

Using VLOOKUP across multiple worksheets for calculations

  1. #1
    Registered User
    Join Date
    12-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Using VLOOKUP across multiple worksheets for calculations

    Hello

    Could someone please give me a shorter formula which would function the same as...

    =VLOOKUP($B4,'1'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'2'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'3'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'4'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'5'!$B$3:$AZ$1000,3,0)

    (and so on - 113 worksheets)

    Thanks for your time...

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Using VLOOKUP across multiple worksheets for calculations

    See if this custome lookup function will do as you need

    If you are asking to pull a value from all the sheets, then you will need code to loop through all the worksheets using the FIND method

    See this add in from Chip Pearson: Find All VBA Function
    Last edited by Palmetto; 12-30-2012 at 08:52 AM.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    12-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Using VLOOKUP across multiple worksheets for calculations

    Thanks for the reply Palmetto.

    I don't think the first function is suitable, since the description states that it stops at the first match it finds (I need to it to continue to find all matches across all worksheets).

    I can't get my head around FindAll (never used those kind of functions before).

    ugh, nevermind. Thanks anyway.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Using VLOOKUP across multiple worksheets for calculations

    You'll find a way to do this, here.

    https://sites.google.com/a/madrocket...ssistant/files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Using VLOOKUP across multiple worksheets for calculations

    See if this is of any help: FlexFind

  6. #6
    Registered User
    Join Date
    12-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Using VLOOKUP across multiple worksheets for calculations

    @Fotis1991: Again that function returns only the 1st match.

    I'm not trying to 'find' a cell value across all worksheets. I'm trying to calculate values in cells that are adjacent to a matched cell in all worksheets.

    Perhaps if I explain what I'm trying to do it'll help

    Lets say I have a main worksheet entitled 'All ingredients' and several other sheets -which contain recipe ingredients- entitled '1-113' . In the 'All ingredients' worksheet, I have the text value 'Bananas' in A1. What I would like to do, is populate the empty cell next to 'Bananas'/A1 (which would be B1) with the total number of 'Bananas' needed for all recipes. So if worksheet '1' has 'Bananas' in cell A100 and the value of '23' in the cell next to it (B100) and worksheet '10' has the same, then in the 'All ingredients' worksheet, I want to populate cell B2 with '46'.

    *EDIT* thanks Palmetto I'll take a look..

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Using VLOOKUP across multiple worksheets for calculations

    If Palmetto's suggestion does not works for you, if you like upload a small sample workbook to work on it. I have an idea using sumif and Indirect functions..

  8. #8
    Registered User
    Join Date
    12-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Using VLOOKUP across multiple worksheets for calculations

    Ok thanks Fotis, here you go.
    Attached Files Attached Files

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Using VLOOKUP across multiple worksheets for calculations

    This one looks to work for me. For you?
    Attached Files Attached Files

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using VLOOKUP across multiple worksheets for calculations

    I have an idea using sumif and Indirect functions..
    Yes, that is what I would do.

    Can you post the formula you came up with?

    It seems that folks use the file attachment option a lot here!

    That's a good option to have but then we can't see the solution unless we download the file.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  11. #11
    Registered User
    Join Date
    12-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Using VLOOKUP across multiple worksheets for calculations

    Yes it works in the sample workbook, but I'm getting a 'NAME#' error in my actual workbook.

    Can I email you my actual workbook?

  12. #12
    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: Using VLOOKUP across multiple worksheets for calculations

    Did you create the Named Range "List" as Fotis' example has?

    You would need to list the names of each sheet you need searched, then select that range and apply the Named Range: List

    Then it should work

    - Moo

  13. #13
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Using VLOOKUP across multiple worksheets for calculations

    @ Tony Valko

    We create a list with all the sheets and Named it as "List"

    Then i used this formula.

    Please Login or Register  to view this content.
    ..It seems that folks use the file attachment option a lot here!
    Yes this is true. For me(as i don't speak English very well) is the best way to understand the point!

    Nice to see here Tony! I have learned a lot from you.

  14. #14
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Using VLOOKUP across multiple worksheets for calculations

    @ neljan

    I just saw your reply.

    Did you do these that MOO(thanks) told?

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using VLOOKUP across multiple worksheets for calculations

    The reason I suggest posting the formula is...

    Say an hour after you post I post the exact same formula.

    However, I didn't download your file so I don't know what solution you came up with. Our formulas are exactly the same so someone may think I just copied your solution and pasted it into a reply when that is not the case.

    Anyhow...

    For this application there is no need to make a list of the sheet names since they appear to be a sequence of numbers. We can do something like this:

    Sheets named 1 to 133...

    =SUMPRODUCT(SUMIF(INDIRECT("'"&ROW(INDIRECT("1:133"))&"'!B5:B1000"),$B5,INDIRECT("'"&ROW(INDIRECT("1:133"))&"'!C5:C1000")))

    Also note that we don't need to use the dollar sign for cell references that are quoted in the INDIRECT function. They will automatically be evaluated as absolute references and they will not change if the formula is copied to other locations.

    Nice to see here Tony! I have learned a lot from you.
    Thank you!

    I hope to make this forum my "home forum" so you'll see me here often.
    Last edited by Tony Valko; 12-31-2012 at 12:46 PM. Reason: I don't know how to spell.

  16. #16
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Using VLOOKUP across multiple worksheets for calculations

    ..Say an hour after you post I post the exact same formula.

    However, I didn't download your file so I don't know what solution you came up with. Our formulas are exactly the same so someone may think I just copied your solution and pasted it into a reply when that is not the case.
    Here the things are different Tony. You have to download my file if you answer a hour...later. And as i said for many of us that we don't speak English well, this is a valuable tool.

    .
    .Also note that we don't need to use the dollar sign for cell references that are quoted in the INDIRECT function. The will automatically be evaluated as absolute references and they will not change if the formula is copied to other locations.
    Thanks for this. I didn't know.

    ...For this application there is no need to make a list of the sheet names since they appear to be a sequence of numbers. We can do something like this:
    I know this,if the sheets are sequence of numbers. In this case i didn't thought that could be. . From whom i know?

    http://www.mrexcel.com/forum/excel-q...uct-sumif.html


  17. #17
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Using VLOOKUP across multiple worksheets for calculations

    use spare column F1: enter 1 then copy down to F150
    Create a name range on column F: MySheets

    =SUMPRODUCT(SUMIF(INDIRECT("'"&MySheets&"'!B3:B1000"),$B4,INDIRECT("'"&MySheets&"'!D3:D1000")))

  18. #18
    Registered User
    Join Date
    12-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Using VLOOKUP across multiple worksheets for calculations

    Thanks for all your help guys!

    Ok I tried Fotis' suggestion and it is working, but if I have 'TrainName1' and 'TrainName1 with 10 carriages' (for example) then both are still calculated (something I can't have).

    Is there a way to make it so that only cells that match exactly are 'found'?

    I have:

    =SUMPRODUCT(SUMIF(INDIRECT("'"&SetList&"'!B3:B1000"),$B4,INDIRECT("'"&SetList&"'!D3:D1000")))

    Again thanks for everything

  19. #19
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using VLOOKUP across multiple worksheets for calculations

    If cell B4 contains the criteria and it contains 'TrainName1' then only cells with that specific entry will be summed. It should not sum cells that contain 'TrainName1 with 10 carriages' .

    I downloaded your file but the sheet names don't match your description in your first post:

    =VLOOKUP($B4,'1'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'2'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'3'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'4'!$B$3:$AZ$1000,3,0)
    +VLOOKUP($B4,'5'!$B$3:$AZ$1000,3,0)

    (and so on - 113 worksheets)
    In the file the sheet names are just random numbers. Is that just to demonstrate what you want or do the sheet names follow the numbering sequence as shown above?

    If the sheet names follow some sort of sequential naming pattern then you don't need to make a list of the sheet names.

  20. #20
    Registered User
    Join Date
    12-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Using VLOOKUP across multiple worksheets for calculations

    Hi Tony

    My mistake, it is working correctly. Thank you so much everyone

    The actual sheet names are:

    107
    375
    379
    383
    452
    483
    487
    493
    497
    560
    646
    1029
    1254
    1255
    1256
    1525
    1552
    1581
    1589
    1592
    1651
    1831
    1854
    1952
    1966
    2140
    2149
    2150
    3438
    3739
    4532
    4535
    4536
    4539
    4547
    4549
    4551
    4552
    4554
    4555
    4558
    4565
    6046
    6054
    6071
    6073
    6074
    6075
    6077
    6079
    6080
    6081
    6085
    6086
    6276
    6277
    6285
    6286
    6335
    6349
    6350
    6361
    6362
    6363
    6364
    6365
    6367
    6370
    6371
    6372
    6373
    6374
    6376
    6378
    6380
    6382
    6390
    6394
    6397
    6399
    6594
    6597
    6683
    6695
    6696
    6746
    6748
    6755
    6761
    6762
    6763
    6765
    6901
    6928
    6940
    6950
    6970
    6971
    7725
    7740
    7745
    7750
    7755
    7760
    7815
    7816
    7820
    7822
    7823
    7824
    7838
    7839
    10027

    So I used the list method.

  21. #21
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using VLOOKUP across multiple worksheets for calculations

    OK, then in that case you would need to use a sheet name list.

+ 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