Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
cg cg is offline
external usenet poster
 
Posts: 11
Default Automatic Alphabetical Sort

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Automatic Alphabetical Sort

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Automatic Alphabetical Sort

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
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---

  #4   Report Post  
Posted to microsoft.public.excel.programming
cg cg is offline
external usenet poster
 
Posts: 11
Default Automatic Alphabetical Sort

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alphabetical sort with formulas Matt Excel Discussion (Misc queries) 0 April 23rd 09 08:15 PM
Alphabetical sort in a macro RichardVisteon Excel Programming 5 July 25th 08 04:45 PM
alphabetical sort Jock Excel Worksheet Functions 4 November 2nd 07 09:59 AM
Sort - Not Alphabetical tommcbrny Excel Discussion (Misc queries) 1 April 16th 07 09:25 PM
sort last names by in alphabetical order Jackie Excel Discussion (Misc queries) 1 May 24th 06 08:45 PM


All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"