Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Bakir Farooq   on Nov 22 In MS Office Category.

  
Question Answered By: Patty Freeman   on Nov 22

Which column?

The following code does it for a change  in column  B of the table  as
signified by the second line's two appearances of "$B$2:$B$84". Right
click the tab of the sheet with the table in and choose 'View Code'
and paste the following in the topmost pane (the one with two dropdown
lists at the top):

Private Sub Worksheet_Change(ByVal Target As Range)
If Union(Target, Range("$B$2:$B$84")).Address = "$B$2:$B$84" Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Range("A1:T84").Select
Selection.Sort Key1:=Range("T2"), Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Application.EnableEvents = True
Target.Select
Application.ScreenUpdating = True
End If
End Sub

Go back to the sheet and test it (I've assumed the table has headers).

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Need help auto-sorting a data table Or get search suggestion and latest updates.


Tagged: