+ Reply to Thread
Results 1 to 3 of 3

Macro to sort worksheet by the column of the active cell

Hybrid View

  1. #1
    Registered User
    Join Date
    03-11-2008
    Posts
    1

    Macro to sort worksheet by the column of the active cell

    I have a worksheet with columns A through Z, full of data. Row 1 is a header containing column names. I am constantly sorting this worksheet this way and that way, and it would save a lot of time if I could just create a macro that would sort the ENTIRE sheet based on active cell. For example if cell J1 was the active cell, and I ran the macro, the worksheet would sort by column J. It is important that the entire sheet is sorted (the data in each row is associated with a different person, and must remain intact). I am using Excel 2003 on Windows XP. I'm not a skilled programmer, but I do know how to edit/create macros in the VBA edit window.
    Last edited by VBA Noob; 03-11-2008 at 08:20 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try

      ActiveSheet.Cells.Sort header:=xlYes, order1:=xlAscending, key1:=Cells(1, ActiveCell.Column)

    rylo

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I've found it convenient to trigger sorting with a Double Click event.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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