View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jim May Jim May is offline
external usenet poster
 
Posts: 477
Default Auto data sort by clicking on column

Here's a small example where I have a table (with 1 row headers) over
Range A1:F7 << Post below code into the Sheet Module Code window.

Simply Right-Click on any Column Header Row (Row 1 in this case)
HTH

Jim May

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
If Not Intersect(Target, Range("A1:F1")) Is Nothing Then
SortCol = ActiveCell.Column
With ActiveSheet.Range("A1").CurrentRegion
.Sort Key1:=Target.Value, Order1:=xlAscending, Header:=xlGuess,
OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End With
End If
End Sub

"Jack C" wrote:

Apparently I can set up a spreadsheet to sort data by placing hot key in the
column indicator cell. (Similar to the newest on top in outlook)
How do I do this??