PC Review


Reply
Thread Tools Rate Thread

Automatic Alphabetical Sort

 
 
CG
Guest
Posts: n/a
 
      21st Nov 2008
I have a vba form which adds a name to the bottom of the list. How so I make
that list of names automatically sort alphabetically.

--
CG
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      21st Nov 2008
Right click on the sheet of interest; paste this code into the window that
opens:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Row >= 1 Then
Range("A1", Range("A1").End(xlDown)).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub

May need a bit of modifying, btu this should be pretty darn close...

Regards,
Ryan---
--
RyGuy


"CG" wrote:

> I have a vba form which adds a name to the bottom of the list. How so I make
> that list of names automatically sort alphabetically.
>
> --
> CG

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      21st Nov 2008
You should disable events within the Change event before making any
changes. Otherwise, the Change event makes a change, that triggers
Change, which makes a change that triggers Change, as so on until you
run out of stack space.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'''
' code
'''
Application.EnableEvents =True
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Thu, 20 Nov 2008 22:13:00 -0800, ryguy7272
<(E-Mail Removed)> wrote:

>Right click on the sheet of interest; paste this code into the window that
>opens:
>
>Private Sub Worksheet_Change(ByVal Target As Range)
>If Target.Column = 1 And Target.Row >= 1 Then
> Range("A1", Range("A1").End(xlDown)).Select
> Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
>End If
>End Sub
>
>May need a bit of modifying, btu this should be pretty darn close...
>
>Regards,
>Ryan---

 
Reply With Quote
 
CG
Guest
Posts: n/a
 
      21st Nov 2008
I am having an Compiled Error: Expected:expression error in the := of
the last 2 lines. What does this mean? Sorry I am new to VBA!
--
CG


"ryguy7272" wrote:

> Right click on the sheet of interest; paste this code into the window that
> opens:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Column = 1 And Target.Row >= 1 Then
> Range("A1", Range("A1").End(xlDown)).Select
> Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
> End If
> End Sub
>
> May need a bit of modifying, btu this should be pretty darn close...
>
> Regards,
> Ryan---
> --
> RyGuy
>
>
> "CG" wrote:
>
> > I have a vba form which adds a name to the bottom of the list. How so I make
> > that list of names automatically sort alphabetically.
> >
> > --
> > CG

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sort alphabetical in report Pierkes Microsoft Access 4 15th Sep 2010 07:41 AM
Alphabetical sort with formulas Matt Microsoft Excel Misc 0 23rd Apr 2009 08:15 PM
alphabetical sort =?Utf-8?B?Sm9jaw==?= Microsoft Excel Worksheet Functions 4 2nd Nov 2007 09:59 AM
Sort - Not Alphabetical =?Utf-8?B?dG9tbWNicm55?= Microsoft Excel Misc 1 16th Apr 2007 09:25 PM
Sort row 4 in alphabetical order Richard Daniels Microsoft Excel Worksheet Functions 0 12th Sep 2003 08:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:29 AM.