+ Reply to Thread
Results 1 to 13 of 13

Sort merged cells

Hybrid View

  1. #1
    Registered User
    Join Date
    01-15-2010
    Location
    Brasil
    MS-Off Ver
    Excel 2000
    Posts
    13

    Sort merged cells

    Hi there,

    i have a problem to sort merged cells in the file attached. i tried via macro but could not reached a good solution. I have 30 plans inside the sheet and even manually is too hard to do it because i use some "=" to not type again every number since some are the same but when i try to sort the lines became diferent values.

    more explanation inside the file.

    Tks for your attention.
    Attached Files Attached Files

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: HOW to sort merged cells

    Why did yuo merge cells? You could rich the same result by enlarging column width.Can't you now unmerge them?

    I suggest you to unmerge em all, then delete unnecesary columns. and set width, say 25 pt.?!
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Registered User
    Join Date
    01-15-2010
    Location
    Brasil
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: HOW to sort merged cells

    Quote Originally Posted by contaminated View Post
    Why did yuo merge cells? You could rich the same result by enlarging column width.Can't you now unmerge them?

    I suggest you to unmerge em all, then delete unnecesary columns. and set width, say 25 pt.?!
    i cannot perform this because the layout of the report that is be set by the big guys out there..

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sort merged cells

    well you can start by unmerging cells then alignment horizontal center across selection instead to give the same appearence
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  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: Sort merged cells

    Try this and see if
    ......the big guys out there..
    notice!

    Sub TidyPasta()
        Cells.MergeCells = False
        r = Cells(1, 1).End(xlDown).Row
        c = Cells(r, Columns.Count).End(xlToLeft).Column + 6
        For i = c To 3 Step -1
            If Cells(Rows.Count, i).End(xlUp).Row = 1 Then
                Columns(i).Delete
            End If
        Next
        r = Cells(Rows.Count, 1).End(xlUp).Row
        For i = r To 2 Step -1
            Range("F" & i & ":G" & i).MergeCells = True
            Range("A" & i & ":B" & i).MergeCells = True
        Next    
        Columns("A:G").ColumnWidth = 12.75
    End Sub
    P.S.

    Before running

    Delete the instructions and result you need to obtain shown in your sample workbook.

    Cheers
    Last edited by Marcol; 02-22-2010 at 09:43 AM. Reason: P.S. added

  6. #6
    Registered User
    Join Date
    01-15-2010
    Location
    Brasil
    MS-Off Ver
    Excel 2000
    Posts
    13

    Re: Sort merged cells

    well, i got some different result in my test here.. please see bellow the result from the code and the result expected.

    result from code resullt expected
    10 00235 01 ==== 10 00231 01
    10 00235 05 ==== 10 00231 08
    10 00235 06 ==== 10 00231 10
    10 00380 07 ==== 10 00231 11
    10 00380 08 ==== 10 00231 12
    10 00380 09 ==== 10 00231 18
    10 00231 10 ==== 10 00235 01
    10 00231 11 ==== 10 00235 05
    10 00231 12 ==== 10 00235 06
    10 00231 18 ==== 10 00380 07
    10 00231 08 ==== 10 00380 08
    10 00231 01 ==== 10 00380 09




    the Columns A and B (as second condition) were not well sorted..
    Last edited by stazevedo; 02-22-2010 at 01:08 PM. Reason: a better explanation

  7. #7
    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: Sort merged cells

    Okay

    Can't do it tonight

    If no one else offers a solution

    Look back early tomorrow

    Cheers

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Sort merged cells

    Avoid Merged Cells like the plague
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  9. #9
    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: Sort merged cells

    Agreed Roy !!!!

    -----but that's what
    ......the big guys out there..
    ......want?

  10. #10
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Sort merged cells

    The source is probably not native Excel but comes from a reporting system like Chrystal Reports or Business Objects. Notorious for putting gazillions of columns in between fields and merging across. Looking at the number of columns involved in the display of five values, I bet that's what it is.

  11. #11
    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: Sort merged cells

    Hi seems nobody else took up the gauntlet

    There are a few hidden traps in this problem.

    1/. Umpteen merged columns - unmerged and redundant cols removed to allow sorting

    2/. Formulae in all tables - removed there seems no good reason for them (when sorted the result is garbage if the formulae is retained.

    3/. Total 12 in example seems to be a count - no formula other totals - formula retained

    4/. All Tables must have 14 rows including Header & Totals rows and must be separated by at least 1 blank row

    5/. I can see no good reason for merging A&B and F&G but that is your request.'comment out or delete as per note in code if you change your mind.


    **********ALL ADVICE IS TO AVOID MERGED CELLS*************

    Have a look at Sheet "1" and then run the code there.

    Best of luck with ......the big guys out there..

    Alistair

    P.S.
    teylyn
    Crystal reports a blast from the past - haven't seen them in years!
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    12-01-2011
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Sort merged cells

    I copied the chart I was trying to sort and pasted it onto the next sheet with "paste as values." Sorted fine after that.
    jwnyc

  13. #13
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Sort merged cells

    @jwnyc,

    I don't see any connection of your comment to the question. Please take heed when posting comments. Have a look at the forum rules before posting anything else.

+ 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