+ Reply to Thread
Results 1 to 32 of 32

Sort by named range or blocks of data with merged cells?

  1. #1
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Sort by named range or blocks of data with merged cells?

    Hi, just wondering if it's possible to sort data by named range when using merged cells. Below image gives a rough idea of what I mean.

    qppbaq.png

    So range from A1 to F5 and named DATA1, range from A6 to F10 is DATA2 and so on. I want to sort by a numeric value in column C. There are many of these blocks of data one underneath the other as shown in the pic but is there a way to treat the range as one entire row, sort by column C and have all the blocks move correctly as is? Excel obviously throws the cannot sort with merged cell error and I need the entire range/block of data to move as one piece.

    Is that possible?

    Thanks
    Last edited by donkey33; 07-23-2016 at 09:25 AM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    Hi Donkey,

    Welcome to the Forum! How many of those records do you have?

    If you'll: Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

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

    I'll take a stab at it
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Hi xladept, thanks for the welcome

    I'll put it together shortly and upload for you.

    Thanking you

  4. #4
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Hi xladept, I have uploaded a basic sheet of what I'm trying to do.

    Basically, just want to sort each group of rows (indicated by color) by the rank figure and have all associated data within those rows move also. So if sorting rank from largest to smallest, name 5/6 should be at the top with all the resulted data 3's.

    Any questions, please let me know and appreciate you taking a look at this.

    Thanks
    Attached Files Attached Files

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    I'll take a look tomorrow unless someone solves it by then

  6. #6
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Thanking you

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    I'm not sure I matched your gray, but try this:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Color definitely isn't an issue. I just added it to highlight the block of rows but I'll most likely take it out.

    I'm stuck at work but I'll be trying this out when I home. Much appreciated and I'll post once I try it out.

  9. #9
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Just tested it and it works with the test example. Only problem I'm having now is applying it to the actual data I have. Keep getting type mismatch or variable errors (I'm not familiar with this kind of stuff).

    The test example was just something I created that doesn't actually mirror the actual data. I probably should have just edited that information instead and uploaded that. Might be an easy fix if you don't mind altering it a little to match that data?

    Also, I have a space in between each block of data. Is there a way to preserve this? If not, I could remove it I guess. It's just for spacing really.

    One other thing, is there a way to have the column and row sizes stay the same size? They seem to default to the original excel sizes and not hold firm on the size already set throwing the merges way off size.

    Thanking you, this is much appreciated.
    Attached Files Attached Files

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    It threw the type mismatch because the Key was no longer in "F" - it's now in "J"

    Try this:

    Please Login or Register  to view this content.
    * If you have a lot of records (10,000 or more), I should change the sort

  11. #11
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Sorry, had to go away on business yesterday but I'm home tomorrow and will try this. Thanks again and many thanks when I get back if it works

  12. #12
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Seems to work well with the test. I couldn't get it to work with my actual data though. Something about object variable so I copied the test sheet over and will need to replace what's in there and use that instead.

    Is it an easy fix to lengthen the number of blocks moved? For example, I have 1-7 ranks and when ordered, there are 7 but when I have 8 or more, after the macro is run, it's only showing the top 7 and not all items. So for a top 30 (for example), it's just showing the top 7 records and that's it.

    How do I fix that?

    Thanks
    Last edited by donkey33; 07-27-2016 at 07:05 AM.

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    There shouldn't be any problem - what is different about the actual data?

  14. #14
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Nothing at all to be honest. I actually copied and pasted from there for the test data so that was the source. I just changed the actual figures and team names otherwise they're identical.

    I can't figure out why it didn't apply across as once I copied the sheet from the test file to the real file, it worked. No idea why but it works.

    Just can't figure out how to have it show more than the 7 ranks. For a top 30, it's only showing the lowest/highest 7 and that's it. Is it easy to make it show all 30? What flag do I need to change?

    Thanks

  15. #15
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    Most probably you have two blank rows between the 7h and 8th entries

  16. #16
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Nah, I just copied and pasted the same upper block (so 14 entries) and all with the same single row between all of them.

    Any ideas?

  17. #17
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    Yeah,

    I'm using a dictionary in that program so duplicate data will be ignored - try it for real

  18. #18
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Spot on man. With the real data or even copied data, as long as the rank key was different, it worked and organise every single entry.

    Thank you so much for this. I would have never been able to work this out and the only option I had was to just create a normal lengthy width table housing all the data. This way I can have certain bits vertically presented which is much better.

    Again, very much appreciated.

  19. #19
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    You're welcome!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  20. #20
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Done, marked as solved

  21. #21
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Me again

    Two areas I'd like to touch up if possible. After entering all my data, having two issues.

    1. Lookup values don't move and just give a reference error. The ranking number is fed from a lookup (simply, equals a cell from another sheet where the calculation is). When processing the macro, is there a way to copy the value of the cell and not the formula?

    2. I have images in a column of cells. The images move fine but the macro somehow copies all the images in the order they are first, then pastes the correctly ranked images over the top of the previous pasted images. So two images, one over the other. Looks like when the new sheet is created, it copies worksheet 1 and then clears contents but it's not clearing the images, only the data. Any way to also clear the images?

    Thanks

  22. #22
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    Hi donkey,

    If this doesn't work then I'll need to see a representative sample - there were no formulas or shapes on the one submitted

    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Works perfectly, thank you again

    I tried a pictures.delete function and it kind of worked but also deleted all the images from the original source. Yours is much better as it leaves the source alone and deleted everything from the newly created sheet.

    Much appreciated again. Hopefully this is the last thing I need adjusting, lol. Seems to work as I want it to now so fingers crossed.

  24. #24
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    You're welcome! Glad it worked - but, any other changes would, probably, require code adjustment

    Don't cross them twice!

  25. #25
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Cross them once more?

    Everything is working well but only the ranking figure values are copied across. All the data is still showing reference lookup errors.

    Is it easy to copy values for all data also?

  26. #26
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    Try this one - I don't clear the shapes because I don't paste them:

    Please Login or Register  to view this content.
    Last edited by xladept; 08-07-2016 at 11:15 AM.

  27. #27
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    It's close but still not quote there.

    I'm using this code right now.

    Please Login or Register  to view this content.
    This works perfectly except all other data in the colums doesn't copy across and I get reference errors as they are lookups. So I grabbed part of the latest code above and replaced the 4th and 5th line from the bottom

    Please Login or Register  to view this content.
    With this

    Please Login or Register  to view this content.
    So now the reference lookup errors are fixed and it pasts the values only but the images in the columns have disappeared. So I have two codes but one has images, the other pasted values but I can't seem to figure out how to combine the two to get both.

    Is it an easy fix?

    Thanks

  28. #28
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    Maybe:

    Please Login or Register  to view this content.

  29. #29
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Thanks, that's now perfect. Not sure how to say thanks enough

  30. #30
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    Hi Donkey,

    Glad it's working - you can thank me by giving me by giving me reputation points - just click on the little star at the bottom left

  31. #31
    Registered User
    Join Date
    07-23-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: Sort by named range or blocks of data with merged cells?

    Done.

    Thanks again

  32. #32
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Sort by named range or blocks of data with merged cells?

    You're welcome and thanks for the rep!

+ 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. How to sort data that is split in merged cells
    By Ankit_Kumar in forum Excel General
    Replies: 1
    Last Post: 06-11-2015, 02:27 AM
  2. 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
  3. [SOLVED] Can you sort & expand column data when cells are merged?
    By lsargent in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-27-2013, 06:37 PM
  4. Sort blocks of data
    By WasWodge in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2012, 04:44 PM
  5. Data Sort & Merged cells
    By HighQualityH2O in forum Excel General
    Replies: 2
    Last Post: 07-06-2009, 07:05 PM
  6. How I sort data in Excel, it keeps saying "merged cells must be ID
    By angela g in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-19-2005, 12:15 AM
  7. Sorting blocks of data or named fields?
    By Greg in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-26-2005, 09:06 AM

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