+ Reply to Thread
Results 1 to 11 of 11

Sort by Merged Cells

  1. #1
    Registered User
    Join Date
    06-17-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    13

    Sort by Merged Cells

    Hello and thanks in advance for the help.

    I am working on a workbook with over 2000 rows. The first row is a header row.
    rows 2 and 3 are related - 4 and 5 are related (and so on)
    Cell A not important to this issue
    Cells B2 and B3 contains item names
    Cell C not important to this issue
    Cell D not important to this issue
    Cells E2 and E3 contain a numeric values
    Cells F2 and F3 are merged and contains a formula that will compare the numeric values in cells E2 and E3 and display the name of the item from cells B2 or B3 with the greater value or the word "tie" if the values are equal. (that formula is done)

    What I need help on is sorting by the merged cells in column F without messing up the data in other columns.
    If that is not possible, Is there a way to highlight the entire row (one color for item name 1 and another color for item name 2) Not worried about the ones that say "tied"

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Sort by Merged Cells

    Attach a workbook with some sample data, showing what you want as a result.

    Go Advanced -> Manage Attachments -> Upload

  3. #3
    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,936

    Re: Sort by Merged Cells

    Merged cells are the devils work LOL - they cause all sorts of problems (like you just encountered)

    1 way around this would be to add a helper column, and create a unique ID for each pair of merges, then use that in the sort
    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

  4. #4
    Registered User
    Join Date
    06-17-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    13

    Re: Sort by Merged Cells

    Thanks again for any help.
    I have attached a sample of how it should look like including merged cells with working formula.

    What I am asking is to be able to sort by last column or to highlight cells based off then input of last column.

    I hope this helps.
    Attached Files Attached Files

  5. #5
    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,936

    Re: Sort by Merged Cells

    Would you only ever have 2 merged cells, or could there be more?

  6. #6
    Registered User
    Join Date
    06-17-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    13

    Re: Sort by Merged Cells

    There will only be 2 merged cells as shown in the example.
    Not belittling you... I got an error message that by answer was too short..

    Thanks again for everything.

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

    Re: Sort by Merged Cells

    OK, I just remembered, you actually cannot sort a table with merged cells

  8. #8
    Registered User
    Join Date
    06-17-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    13

    Re: Sort by Merged Cells

    What about conditional formatting?
    Do you know of a rule that I can apply highlighting rows based off the merged cells?

    Thanks again..

  9. #9
    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,936

    Re: Sort by Merged Cells

    So you want all name 1's 1 color, all name 2's another color etc. How many names could you have? Remember, each color is a new rule

  10. #10
    Registered User
    Join Date
    06-17-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    13

    Re: Sort by Merged Cells

    Correct but only from the merged cells. the names in column B will only be name 1 or name 2.

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

    Re: Sort by Merged Cells

    Expanding on Ford's suggestion of a helper column (G), which could be moved and/or hidden for aesthetic purposes, it could be populated using: =IF(F2<>"",F2,G1)
    Sheet1 shows how it could be used to apply conditional formatting. The CF rules are:
    For Name 1: =$G2="Name 1"
    For Name 2: =$G2="Name 2"
    Both rules are applied to the range $A$2:$F$11
    Sheet2 shows that if the range is converted into a table you could either sort or filter using the helper column although you would unmerge the formatting either way.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. [SOLVED] Sort merged cells
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2016, 05:10 PM
  2. How to sort merged cells ?
    By ch.snyers in forum Excel General
    Replies: 3
    Last Post: 10-04-2013, 12:31 PM
  3. Data sort, empty formula cells to bottom merged cells!
    By ikkuh in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-09-2013, 03:10 AM
  4. Sort merged cells
    By stazevedo in forum Excel General
    Replies: 12
    Last Post: 12-01-2011, 03:42 PM
  5. Sort and merged cells
    By asyrip in forum Excel General
    Replies: 1
    Last Post: 09-26-2006, 01:31 PM
  6. [SOLVED] How to sort merged cells
    By Sort merged cells in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-11-2005, 01:06 PM
  7. [SOLVED] How to sort merged cells
    By imaorange in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-11-2005, 12:06 PM

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