+ Reply to Thread
Results 1 to 12 of 12

Linking to last record in a spreadsheet

  1. #1
    Registered User
    Join Date
    12-31-2008
    Location
    Alaska, (not Anchorage)
    MS-Off Ver
    Excel 2010, 2016, and 365
    Posts
    78

    Linking to last record in a spreadsheet

    Hello all,

    I am formatting a workbook so that the first table is a flat database of information used in other tables in the workbook. Each row in the tables would correspond to the values for a specific year thus,

    year|weight|length
    1999|24|123
    2000|27|134
    2001|21|121
    2002|25|132
    2003|19|112
    2004|31|135
    2005|22|126
    2006|27|145
    2007|28|147


    I would like to have other tables reference this table and automatically update for the last record in the table so that the second table in the workbook would show,

    year|weight|length
    2007|28|147

    My goal is to be able to go into the first table flat database tomorrow (Jan 1, 2009) and insert,

    2008|29|110

    in row below the 2007 data and then have the other tables in the workbook automatically update to reflect this new data and show

    year|weight|length
    2008|29|110

    Is there a simple way to do this? Thanks.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    as they are just numbers use the max function in a look up
    =MAX(A:A) would return 2009
    something like
    =VLOOKUP(MAX(A:A),A:C,2,FALSE)

  3. #3
    Registered User
    Join Date
    12-31-2008
    Location
    Alaska, (not Anchorage)
    MS-Off Ver
    Excel 2010, 2016, and 365
    Posts
    78

    Like this...almost

    Doesn't populate the weight and length columns for the MAX year.... Thanks.
    Last edited by portsample; 01-03-2009 at 04:40 PM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Or given they are all numbers and assuming there is no data beneath the last row on your Data sheet you could just use LOOKUP:

    Year: =LOOKUP(9.9999E+307,Data!A:A)

    and copy the above across to the right for Weight & Length (assuming Weight is in B and Length C on Data sheet)

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    thats coz you referenced the sheet youre on not the data sheet
    in b1
    =VLOOKUP(MAX(data!$A:$A),data!$A:$C,2,FALSE)
    and in
    in c1

    =VLOOKUP(MAX(data!$A:$A),data!$A:$C,3,FALSE)

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    still curious as to why you would advocate VLOOKUP & MAX rather than just LOOKUP ? More calcs & more committed to memory.

  7. #7
    Registered User
    Join Date
    12-31-2008
    Location
    Alaska, (not Anchorage)
    MS-Off Ver
    Excel 2010, 2016, and 365
    Posts
    78
    Veeeery nice!

    If only all of my tables were this simple.

    Attached is a slightly more complex table that is more generally like what I use in reports where historical data is listed as well as the previous 10-year average and other manipulations.

    The only other problem is that while the data table grows as records are added, the referencing tables are static in numbers of records.

    Any other ideas regarding a better way to skin this cat?

    Thanks for the input and suggestions. Cheers!.
    Last edited by portsample; 01-03-2009 at 04:40 PM.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    donkyote its only that vlook up is often easier to use. look up requires ordered data
    (then again i prefer index/match) but calcs+memory are not really an issue .
    portsample
    MAX(data!A:A)-10 whats the -10 all about?

  9. #9
    Registered User
    Join Date
    12-31-2008
    Location
    Alaska, (not Anchorage)
    MS-Off Ver
    Excel 2010, 2016, and 365
    Posts
    78
    MAX(data!A:A)-10

    This selects the cell in column A ( or "year") that is 10-years prior to the maximum value (current "year") to produce a table of the current year (2008) and the previous 10-yrs values for use in a 10-yr average.

    year weight length length/wt
    1998 34 202 5.94
    1999 24 123 5.13
    2000 27 134 4.96
    2001 21 121 5.76
    2002 25 132 5.28
    2003 19 112 5.89
    2004 31 135 4.35
    2005 22 126 5.73
    2006 27 145 5.37
    2007 28 147 5.25
    prev 5yr avg 25.4 133 5.32
    2008 56 301 5.38

    Is there an easier way to do this: am I missing something? BTW, thanks for your help in this issue...this has been incredibly useful. Cheers and, hey HAPPY NEW YEARS!

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Quote Originally Posted by martindwilson View Post
    donkyote its only that vlook up is often easier to use. look up requires ordered data
    (then again i prefer index/match) but calcs+memory are not really an issue .
    portsample
    MAX(data!A:A)-10 whats the -10 all about?
    The order of data in the context of the original question was (technically) not important as the OP was looking to return the "last value entered" -- using LOOKUP with BIGNUM would always give the correct result (ie last value) given Binary Search algorithm employed.

    That said I concede that having seen the latest Q an INDEX/MATCH approach is the way to go... unless the table is 2 columns I see little reason for ever using VLOOKUP.

    Portsample -- what is you're trying to simplify -- from what I could see of your file it was working, no ? You could switch to an INDEX/MATCH approach such that:

    B2: =INDEX(data!B:B,MATCH($A2,data!$A:$A,0),1)
    this can be applied across range B2:C11

    And also change your formula in A such that:

    A2: =$A13-10

    Then change:

    A3: =$A2+1
    copy to A11

    reduces calcs size a little ...

    Or you could use

    A2: =$A$13-(12-ROW())
    and apply across A3:A11

    Doing either of the above would reduce (to a negligible level) the size of the calc you're performing.

  11. #11
    Registered User
    Join Date
    12-31-2008
    Location
    Alaska, (not Anchorage)
    MS-Off Ver
    Excel 2010, 2016, and 365
    Posts
    78
    Very sweet.

    One more minor question:

    Some of the generated tables are historical and show previous values. Using the structures that we've been discussing there is only a fixed number of records in the table so that if I were to enter 2009 values in my data table (shown below),

    year | weight | length | length/wt
    2001 | 21 | 121 | 5.76
    2002 | 25 | 132 | 5.28
    2003 | 19 | 112 | 5.89
    2004 | 31 | 135 | 4.35
    2005 | 22 | 126 | 5.73
    2006 | 27 | 145 | 5.37
    2007 | 28 | 147 | 5.25
    prev 5yr avg | 25.4 | 133 | 5.32
    2008 | 56 | 301 | 5.38

    ...then the 2001 values will be bumped thusly:

    year | weight | length | length/wt
    2002 | 25 | 132 | 5.28
    2003 | 19 | 112 | 5.89
    2004 | 31 | 135 | 4.35
    2005 | 22 | 126 | 5.73
    2006 | 27 | 145 | 5.37
    2007 | 28 | 147 | 5.25
    2008 | 56 | 301 | 5.38
    prev 5yr avg | 25.4 | 133 | 5.32
    2009 | 19 | 112 | 5.89

    Question: Is there a good way to configure the generated table so that records are added to it as they are also added to the data table? This would result in the following table w/2001 not being "bumped" when 2009 data is added.

    year | weight | length | length/wt
    2001 | 21 | 121 | 5.76
    2002 | 25 | 132 | 5.28
    2003 | 19 | 112 | 5.89
    2004 | 31 | 135 | 4.35
    2005 | 22 | 126 | 5.73
    2006 | 27 | 145 | 5.37
    2007 | 28 | 147 | 5.25
    2008 | 56 | 301 | 5.38
    prev 5yr avg | 25.4 | 133 | 5.32
    2009 | 19 | 112 | 5.89

    I've attached a copy of the table that we've been discussing that uses Index and Match to retrieve values from a reference table.

    Thanks for insight and advice rendered.
    Last edited by portsample; 01-04-2009 at 07:39 PM.

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    reversing the order would make your life a lot easier... it's late so I've probably come up with an inefficient method to do this... but have provided 2 examples in either order... both make use of a helper cell or two (the first only one though the 2nd uses a few more).

    In reality this task is only tricky in Asc order (as you no doubt know) because of the prior 5 year avg requirement in a table of varying length ... if you didn't have that (or it were in a fixed location) your life would be simpler still...

    Needless to say there are ten different ways to skin this cat so there will be other solutions offered I'm sure and it's late so I've no doubt reinvented the wheel somewhere along the line...

    (note: I switched the INDEX/MATCH to LOOKUP given your source data is sorted in asc order (saves typing!))
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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