![]() |
|
#1
|
|||
|
|||
|
I need to sort this automatically every time a new data is entered, I need the last name sorted ascending with all it's information in columns B,C, D, E. How do I do that? file attached |
|
#2
|
||||
|
||||
|
Hello,
May be try this: Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Lig As Long, c As Long, Plage As Range
Lig = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 1
Set Plage = ActiveSheet.Range("E4:E" & Lig)
If Not Intersect(Target, Plage) Is Nothing And Target.Count = 1 Then
With ActiveSheet
Lig = .Cells(Rows.Count, 1).End(xlUp).Row
Set Plage = ActiveSheet.Range("A4:E" & Lig)
For c = 5 To 2 Step -1
Plage.Sort _
Key1:=.Range(.Cells(4, c), .Cells(Lig, c)), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Next c
End With
End If
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Excel 2007 - formula or macro/vba code required | wrighty50 | Excel Programming | 3 | 05-13-2012 02:24 PM |
| Check box macro help needed | Aflac | Word | 4 | 03-24-2012 07:11 PM |
Callout macro needed - Help please
|
Peter Denly | Word VBA | 19 | 07-20-2011 03:30 AM |
| Macro for automatic sorting | Ziggy-R | Excel | 13 | 10-04-2010 06:57 PM |
| automatic start of macro + help on writing helper function | vsempoux | Word | 3 | 10-09-2009 03:01 AM |