+ Reply to Thread
Results 1 to 6 of 6

Sort a partial block of data of variable length

  1. #1
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Sort a partial block of data of variable length

    I want to sort a list of names in a table in alphabetical order - easy enough. But I want only to sort a limited block containing these names but NOT any entries below the list of names. I have used the following VBA code to try to accomplish this task and two images showing the selection of only the names and then the resulting sorted list. You will note that the line below the list of names that was not selected has also also been sorted - which is not what I want to happen. There is a header cell at B5 and the first name in the list is in cell B6.

    I would be grateful for any assistance.

    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by kencoburn; 05-15-2017 at 06:10 AM.

  2. #2
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Sort a partial block of data of variable length

    Is your table a Data table? that might complicate things, might not.

    A sample workbook in this instance would be required.

    Thanks
    Please do add reputation where you see fit, it's nice to be nice and we all enjoy a pat on the back

    Please also mark your thread as solved once it has been.

  3. #3
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Sort a partial block of data of variable length

    The cells adjacent to the names in column C have the following formula format:

    =VLOOKUP(B145,'Nov 2016'!D:Z,13,FALSE)+VLOOKUP(B145,'Dec 2016'!D:Z,13,FALSE)+VLOOKUP(B145,'Jan 2017'!D:Z,13,FALSE), etc up to 'Oct 2017'

    The line that I do not want sorted has no formula in row C, only a value.

    Do you want me to append a copy of the relevant worksheet and, if so, how do I go about doing that.

    Thanks for responding so quickly.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Sort a partial block of data of variable length

    Originally Posted by Pete_UK
    To attach a file, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Sort a partial block of data of variable length

    I have attached a copy of the worksheet shown above. The worksheet is part of a relatively complex workbook which is controlled
    by command buttons in another worksheet and underlying VBA code, in addition to the small section of VBA code above. The full workbook
    size is 1.6 MB.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Sort a partial block of data of variable length

    It occurs to me that a fuller extract of the Form vba code may help to resolve the above problem. I have had to delete repetitive code because of the limit imposed by this forum.

    You will see that the code used to insert names and then sorts them alphabetically for each monthly worksheet that is named Nov 2016, Dec 2016, ....etc. is almost exactly the same as the code used for the events worksheet (e.g. Vets & Partners). I have entered a new transaction manually at the bottom of the monthly worksheets, leaving a space below the list of names, and it sorts properly (does not include the added transaction). Yet when I do the same for the event worksheets the added transaction gets sorted - which is not what I want.

    Please Login or Register  to view this content.

+ 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. Sort a block of data of variable length
    By kencoburn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2017, 01:10 PM
  2. Replies: 2
    Last Post: 08-22-2014, 03:55 AM
  3. [SOLVED] Trying to sort using a variable for length of spreadsheet
    By Fyredancer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2013, 02:09 PM
  4. [SOLVED] Needs to Sort a block of Data by Title A-Z and keep rows togther.
    By Myers4tires in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-28-2012, 12:00 PM
  5. Replies: 6
    Last Post: 04-14-2012, 04:07 AM
  6. Sort Ascending for variable Report length
    By Hblbs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2009, 08:33 AM
  7. Graph with variable data length
    By snoach in forum Excel General
    Replies: 1
    Last Post: 05-27-2005, 05:15 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