+ Reply to Thread
Results 1 to 8 of 8

Transferring the Last Piece of Data in a Column from One Worksheet to Another?

  1. #1
    Registered User
    Join Date
    07-20-2010
    Location
    England, UK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Thumbs up Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    Hi,

    I have a little problem:

    I have an excel document containing 2 worksheets. One is called 'Purchase Order File', and one is called 'Purchase Order Note'.

    'Purchase Order File' is a simply a list of orders made by a business, the most recent of which is at the bottom of the list. This sheet contains values such as 'description', 'price, etc in columns for each order.

    The 'Purchase Order Note' worksheet is a formatted order sheet, with the company logo, etc, which is updated each time a new order is made and printed for the company records.

    What I would like to do is to take the most recent entries in each column of the 'Purchase Order File' workbook (i.e the bottom values on the page) and transfer them to cells in the 'Purchase Order Note' workbook.

    I have found a formula which almost does what I want:

    =INDEX(A:A,MATCH(REPT("z",255),A:A))

    This formula finds the last text value in column A, I would like to know how to find the last text value in column A, in another worksheet....

    Any help is much appreciated!

    Thanks

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,779

    Re: Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    This uses the formula you provided...

    =INDEX('Purchase Order File'!A:A,MATCH(REPT("z",255),'Purchase Order File'!A:A))

    This is a straightforward translation of your formula so I haven't tested in on a mockup workbook. But I have no idea what you are doing with matching 255 z's. As near as I can tell, this formula will either return an error if the MATCH fails, or 255 z's. Doesn't sound useful.

    If this doesn't do what you want, post your workbook if it doesn't contain proprietary/private data.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    Maybe in the sheet you want to query in say cell A1
    Please Login or Register  to view this content.
    Provided the workbook has been saved this will return the sheets name.


    Then using a UDF
    Please Login or Register  to view this content.

    Entered as
    Please Login or Register  to view this content.

    A bit convoluted but it seems to work.

    Hope this helps
    Attached Files Attached Files
    Last edited by Marcol; 07-20-2010 at 07:36 PM. Reason: Redundant code removed from workbook
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Registered User
    Join Date
    07-20-2010
    Location
    England, UK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    Thanks for the quick replies guys.

    6String - I have absolutely no idea what z 255's are, I just copied from a help website I found. Please tell me to remove them if you don't think they're required!

    Marcol - is it really that complicated?! I really hope not as I am far from an expert with these things. Simply put, all i want to do is to take the piece of data at the bottom of a column in Sheet 1, and copy it into a specific cell in Sheet 2.. The difficulty for me is that the data at the bottom of the column has a different row number each time a value is added. Hope this makes sense?

    Thanks again, it is much appreciated

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    It's not really complicated, just novel.

    Have you tried the demo workbook?

    Try adding or deducting from column D in sheet2 and see the results on all sheets.

    Once setup it needs no changing. The function
    Please Login or Register  to view this content.
    is just a way to allow easy selection of the required sheet name.

    You could just use the UDF (User Defined Function) and enter it so
    Please Login or Register  to view this content.

    Cheers

  6. #6
    Registered User
    Join Date
    07-20-2010
    Location
    England, UK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    Thanks Marcol, I've tried your example and it seems to work fine.

    I understand the =LastValue(D:D,"MySheetName") part, but im not sure why =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255) is required? Also can this be done without the file being saved first?

    Lastly, what if my cell contains text rather than data?

    thanks again

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,779

    Re: Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    Quote Originally Posted by 6StringJazzer View Post
    This uses the formula you provided...

    =INDEX('Purchase Order File'!A:A,MATCH(REPT("z",255),'Purchase Order File'!A:A))

    This is a straightforward translation of your formula so I haven't tested in on a mockup workbook. But I have no idea what you are doing with matching 255 z's. As near as I can tell, this formula will either return an error if the MATCH fails, or 255 z's. Doesn't sound useful.
    I have done a little research on this and the 255 z's does work. Here's how. It's "clever."

    First, this formula is only useful for searching a column of text data. MATCH has a third argument, which indicates how you want it to match (exact match, greatest value less than sought, lowest value greater than sought). Here is it omitted, so it takes the default of finding the greatest value that is less than the match value provided as the first argument. However, there seems to be a twist. Using that default, MATCH expects the data to be in an ascending sort order. Microsoft does not document how it behaves when the data is not sorted. Because a string of 255 z's is pretty much the highest-value string possible, MATCH will never find a value greater than that so it seems to bottom out on the last row if the data is not sorted.

    For numeric data, 9.99999999999999E+307 would seem to work the same way.

    You may want to try this to see whether you prefer this to the one you've already tried. I've experimented and it seems to work fine without the need for any VBA.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Transferring the Last Piece of Data in a Column from One Worksheet to Another?

    See this link

    http://www.exceltip.com/st/Cell_Func..._Path/180.html

    1/. The advantage in using and referencing this formula is that if you change the sheet name the UDF will update to suit, it can go in any free cell you wish, in the sheet you want to find the last value.
    The workbook must be saved for this to work, because a filename doesn't exist until it has.

    If you just use the UDF so
    Please Login or Register  to view this content.
    If you rename "Sheet1" to "MySheetName"
    Then the formula must be changed to
    Please Login or Register  to view this content.

    If you put the sheet name in say A1 anywhere in the workbook then use the UDF so
    Please Login or Register  to view this content.
    the UDF will update, but if you now rename the sheet then you must match A1 to the new name.

    By using
    Please Login or Register  to view this content.
    Updates will be automatic.

    It is easier to try the permutations than explain them in words.

    2/. It doesn't matter what last value in the column is, the UDF will return it.
    Date, Time, Currency, etc. ... formatting will not however be matched,

    3/. If however you have formatted values, try this
    Please Login or Register  to view this content.
    Use with
    Please Login or Register  to view this content.
    to get maximun benefit

    Hope this helps

+ 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