Autosorting a league table

  • Thread starter Thread starter joncurtis199
  • Start date Start date
J

joncurtis199

In one of my sheets I want to automatically sort a table after I have
edited a specfic cell. I can make the macro to select the cells to
sort and then what to sort them by, but I don't know how to go about
activating the macro when a cell (in a range of cells) is edited. Can
anyone help me please?
 
Hi
you may use either the worksheet event 'worksheet_change' or
'worksheet_selectionchange'. e.g. put the following code in your
worksheet module

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A1:A100")) Is Nothing Then Exit Sub
On Error GoTo CleanUp:
Application.EnableEvents = False
' enter your code a call your existing macro

CleanUp:
Application.EnableEvents = True
End Sub

This will call your code/macro if a cell in the range A1:A100 is edited
 
Back
Top