+ Reply to Thread
Results 1 to 2 of 2

Excel 2007 : Sorting By Clicking Columns

Hybrid View

jtinebra Sorting By Clicking Columns 12-30-2008, 03:06 PM
VBA Noob Maybe a event macro code... 12-30-2008, 03:28 PM
  1. #1
    Registered User
    Join Date
    12-30-2008
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    Sorting By Clicking Columns

    Hi, I am trying to create an Excel spreadsheet for my workplace, that is VERY simple to use for my coworkers that aren't as computer savvy.

    Instead of having to go to sort commands and what not to sort different things is there any way to have the columns sort (alphabetically) by clicking the column (A, B or C).

    So for example if I want the many rows to be sorted alphabetically based on the "A column value" I would hit the "A" column. Or if I was looking for the rows sorted by their "C column Value" just clicking the "C" column and everything will rearrange itself accordingly.

    Looking forward to a reply back!

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe a event macro

    code goes in the sheet module instead of a normal module.

    Double click the header in Row 1 to run.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Cells.Count > 1 Then Exit Sub
        If Not Intersect(Target, Rows(1)) Is Nothing Then
        Cancel = True
    Application.ScreenUpdating = False
            With Target
                .CurrentRegion.Sort Key1:=.Offset(1), Order1:=xlAscending, Header:=xlGuess, _
                OrderCustom:=1, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
            End With
        End If
    Application.ScreenUpdating = True
    End Sub
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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