View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Biff
 
Posts: n/a
Default Sort a column automatically

Why create a command button when you can just use the sort button on the
formatting toolbar?

Biff

"Richard" wrote in message
...
You might want to try this method using a command button. Substitute what
you
need!
Private Sub CommandButton1_Click()
Me.CommandButton1.Caption = "Sort" 'The CommandButton1 Properties Take
FocusOnClick must be set to False
Dim rng As Range, rng1 As Range
With Worksheets("Sheet1")
Set rng = .Range(.Cells(2, "A"), .Cells(Rows.Count, "A").End(xlUp))
Set rng1 = .Cells(2, "A").End(xlToRight)
Set rng = rng.Resize(, 3)
rng.Sort _
Key1:=.Range("A2"), _
Order1:=xlAscending, _
Header:=xlNo
End With
Application.OnTime Now + TimeSerial(0, 0, 2), _
ThisWorkbook.Name & "!ResetCaption"
CommandButton1.Caption = "Sorting..."
End Sub

"Longtime" wrote:

Is there a way to automatically sort a column in ascending order while
entering numbers so that the column is sorted when last number is
entered.
Appreciate all help.