+ Reply to Thread
Results 1 to 8 of 8

Help in Sorting Unknown Cell Range Alphabetically

  1. #1
    Registered User
    Join Date
    02-22-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    25

    Help in Sorting Unknown Cell Range Alphabetically

    Hello All, I am having problems on how to sort data alphabetically by means of excel code that will just let the user press the button and sort the data automatically.

    I need to sort the data Alphabetically by Last Name. Problem is, I can only sort the whole column of the Last Name itself. I can't sort the adjacent columns with the Last Name column. Thats why whenever I sort it, only the last Name column moves, the others don't.

    Also, the number of people in the excel worksheet may also vary. Therefore I need to adjust my program based on the number of people listed in the Excel Sheet.

    I could record the macro, but that doesn't solve my range problem.

    How can I adjust the Range and sort them alphabetically? Here is the attached excel workbook for my project.

    Any help is greatly appreciated. Thank you ;D
    Attached Files Attached Files

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Help in Sorting Unknown Cell Range Alphabetically

    Hi crisshinn,
    Why dont you just use the Data > Filter?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    02-22-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Help in Sorting Unknown Cell Range Alphabetically

    Quote Originally Posted by pike View Post
    Hi crisshinn,
    Why dont you just use the Data > Filter?
    What do you mean Data > Filter? Why would I Filter the selection? xD I do know of the Data > Sort.

    Sorry I really need to code this in Macro Excel.

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Help in Sorting Unknown Cell Range Alphabetically

    A recorded macro results
    Please Login or Register  to view this content.

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Help in Sorting Unknown Cell Range Alphabetically

    and with code cleaned-up
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-22-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Help in Sorting Unknown Cell Range Alphabetically

    Hi, sorry for the double post, That code works assuming that I know the whole range of my list.

    But the list can increase depending on the number of people added in the file.
    Last edited by crisshinn; 03-21-2011 at 06:25 AM.

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Help in Sorting Unknown Cell Range Alphabetically

    Hi crisshinn

    "Worksheets("Sheet1").Cells(Rows.Count, 3).End(xlUp).Row" will find the last row in dynamic list

    Please Login or Register  to view this content.

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Help in Sorting Unknown Cell Range Alphabetically

    or
    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)

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