Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2012, 04:21 PM
chefmate chefmate is offline I need help with macro...code needed for automatic sorting Windows XP I need help with macro...code needed for automatic sorting Office 2003
Novice
I need help with macro...code needed for automatic sorting
 
Join Date: Aug 2012
Posts: 1
chefmate is on a distinguished road
Default I need help with macro...code needed for automatic sorting


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
Attached Files
File Type: xls MIST PATIENT LIST4.xls (57.5 KB, 15 views)
Reply With Quote
  #2  
Old 08-26-2012, 01:04 AM
mth's Avatar
mth mth is offline I need help with macro...code needed for automatic sorting Windows 7 32bit I need help with macro...code needed for automatic sorting Office 2007
Novice
 
Join Date: Aug 2012
Location: France
Posts: 3
mth is on a distinguished road
Default

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
m
Attached Files
File Type: xls Copie de MIST PATIENT LIST4.xls (69.0 KB, 8 views)
Reply With Quote
Reply



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
I need help with macro...code needed for automatic sorting 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft