+ Reply to Thread
Results 1 to 5 of 5

Script to sort selected text

  1. #1
    Registered User
    Join Date
    08-03-2007
    Posts
    2

    Script to sort selected text

    I'm admittedly new to VB, and am having a hard time writing code for a button which will sort only the selected cells (not the whole sheet, not a specified range of cells) in descending order, first by data in column A, then by Column B, then by Column C.

    Can someone please help? I have a feeling this is not as hard as I think it is.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Can you give an example of what you're trying to sort? Is it completely random, like A2, A7, A49, B18, C10, D19, D22?

    If explaining it won't do it justice, try zipping up a sample file and uploading it to the forum.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Select cells. Start the Macro recorder. Do the sort. Stop the macro recorder.

    When you look in the editor, you should see one line (Plus some Sub declaration , End Sub and some comments.)

    The line starting

    Please Login or Register  to view this content.
    is the one you want.

  4. #4
    Registered User
    Join Date
    08-03-2007
    Posts
    2
    Thank you! That worked perfectly. I simply needed to start recording the macro AFTER making the cell selection. (I knew it had to be easy.)

    My worksheet now correctly sorts (don't laugh!) combatants for my Dungeons & Dragons game by initiative, dexterity, and random ID number... I think I've taken "geek" to a whole new level. Many thanks!

    -Karen

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Are you sure its not "nerd"?

+ 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