+ Reply to Thread
Results 1 to 16 of 16

Keep the references after sorting

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Lightbulb Keep the references after sorting

    Take a look at the spreadsheet.

    The references will change after sorting and break the calculations.
    Absolute referencing is not an option. The table has to be copied periodically to another sheet and placed it at a different row (the columns are identical). Absolute referencing will break the calculations after copying.

    I would like to keep the references unchanged. One idea is to use formulas to maintain references.
    For example, S75 contains:
    =T70
    Change it into:
    =(the address of the Count data cell)

    What formulas could I use to achieve this?

    If no formula could do, I need to resort to macro. Use absolute referencing ($T$70) first. Then run a macro which change all selected cells into relative referencing (T70) every time it needs to be copied. Only the reference of T70 needs to be changed, not any others. I don't know how to code. Could anyone help? Thanks a lot.

    Other links:
    https://www.mrexcel.com/forum/excel-...r-sorting.html
    Attached Files Attached Files
    Last edited by mastertonn; 08-27-2018 at 04:45 PM.

  2. #2
    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,946

    Re: Keep the references after sorting

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    Please make sure to include the full link, so that other members will be permitted to continue helping you

    Note that if you have fewer than 10 posts, you may need to type the link, or past it in pieces (or ask a mod to do that for you)
    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

  3. #3
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Re: Keep the references after sorting

    It has been included. It hasn't been solved yet. Thanks.

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

    Re: Keep the references after sorting

    Rather than post a link to an online sight, which does not allow editing, upload a small (clean) sample workbook (not a pic) here, of what you are working with, and what your expected outcome would look like.

  5. #5
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Re: Keep the references after sorting

    I believe you could choose to download the copy when you visit the online worksheet.

    How could I upload a worksheet file here? I clicked on the attachment icon but it does nothing. It's weird.
    Thank you for your help.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Keep the references after sorting

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Re: Keep the references after sorting

    Thank you. The file has been attached.
    Last edited by AliGW; 10-01-2018 at 01:32 AM. Reason: Unnecessary quotation removed.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Keep the references after sorting

    Add the sheet references to the formulas and sort as you like:

    N
    O
    P
    Q
    R
    S
    T
    U
    V
    W
    69
    70
    Count
    5
    71
    ID Title Title Title Title Low High Title
    72
    1
    xxx xxx xxx xxx
    2
    9
    73
    2
    xxx xxx xxx xxx
    10
    11
    74
    3
    xxx xxx xxx xxx
    3
    15
    75
    4
    xxx xxx xxx xxx
    6
    8
    A S75: =Table!T70+1 T75: =Table!S75+2
    76
    5
    xxx xxx xxx xxx
    5
    6.5
    B S76: =Table!T70 T76: =Table!T70+1.5
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Re: Keep the references after sorting

    Thank you for your reply.
    It is similar to using absolute referencing. It could solve the issue of sorting. However it will be broken when you copy the table to another sheet.
    Last edited by AliGW; 10-01-2018 at 01:32 AM. Reason: Unnecessary quotation removed.

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,681

    Re: Keep the references after sorting

    Since the columns are identical, perhaps the following will help.
    1) For cell S76: =INDEX(T:T,MATCH("Count",S:S,0))
    2) For cell S75: =INDEX(T:T,MATCH("Count",S:S,0))+1
    3) For cell T76: =INDEX(T:T,MATCH("Count",S:S,0))+1.5
    4) For cell T75: =S75+2 (since the formula in this cell only references the cell to its immediate left)
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  11. #11
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Re: Keep the references after sorting

    Thank you for your reply. Unfortunately it does not work since the table will periodically copied to another sheet. There are more than one instance of the "Count" cell in the another sheet (whose name is "record" in the sample spreadsheet).
    Last edited by AliGW; 10-01-2018 at 01:33 AM. Reason: Unnecessary quotation removed.

  12. #12
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,681

    Re: Keep the references after sorting

    The sample workbook attached to post #1 only has sheets named 'Table', 'Sheet2' and 'Sheet3'. It may help us find a resolution if you could provide a sample that is closer to a desensitized/non proprietary version of the actual workbook.
    Let us know if you have any questions.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Keep the references after sorting

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below.

  14. #14
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Re: Keep the references after sorting

    OK thanks for the reminder, AliGW.

  15. #15
    Registered User
    Join Date
    07-16-2014
    Location
    UK
    MS-Off Ver
    2016
    Posts
    90

    Re: Keep the references after sorting

    Quote Originally Posted by JeteMc View Post
    The sample workbook attached to post #1 only has sheets named 'Table', 'Sheet2' and 'Sheet3'.
    The spreadsheet stored online has the "record" sheet. You could take a look at:
    https://1drv.ms/x/s!Alp_NMIveFajft1a7RtdYJ930Bc

    Ignore the attached file in the first post. I cannot update the attached file anymore.
    Thank you for your help.
    Last edited by AliGW; 10-01-2018 at 05:38 AM. Reason: Long quotation edited.

  16. #16
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,681

    Re: Keep the references after sorting

    Perhaps something similar to the following might work:
    1) Turn the range N71:U76 into a table,
    2) Populate S76 using: =INDIRECT(ADDRESS(ROW(Table1[[#Headers],[High]])-1,20))
    3) Since the values of the other cells can be derived based on the value of S76:
    4) For S75 use: =INDEX([Low],MATCH("B",[Title5],0))+1
    5) For T75 use: =INDEX([Low],MATCH("B",[Title5],0))+3
    6) For T76 use: =INDEX([Low],MATCH("B",[Title5],0))+1.5
    To test the table and accompanying 'Count' cells were copied into the Record sheet replacing the cells in range N10:U16
    Let us know if you have any questions.
    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)

Similar Threads

  1. References goes wrong after sorting
    By sfs in forum Excel General
    Replies: 17
    Last Post: 10-02-2018, 04:36 PM
  2. [SOLVED] First Thread - Sorting and cell references
    By TomW23 in forum Excel General
    Replies: 9
    Last Post: 01-31-2018, 05:57 PM
  3. Sorting with Cell References
    By tangerinezebra in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-04-2016, 11:40 AM
  4. Dynamic Sorting - error with references
    By Grimace in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2011, 10:30 PM
  5. Sorting Changes Cell References
    By Camp2 in forum Excel General
    Replies: 2
    Last Post: 06-20-2008, 03:41 PM
  6. Sorting of References for Formulas
    By fak119 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-27-2006, 12:40 PM
  7. Sorting lists with references
    By jonfu in forum Excel General
    Replies: 1
    Last Post: 10-18-2005, 06:05 PM

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