A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Automatically alphabetize excel worksheet



 
 
Thread Tools Display Modes
  #1  
Old September 24th 07, 10:20 PM posted to microsoft.public.excel.worksheet.functions
TanaMary
external usenet poster
 
Posts: 9
Default Automatically alphabetize excel worksheet

Where do I enter a string in the "worksheet code" to automatically
alphabetize my worksheet by the names in the A column. I have the string, I
just don't know how to access the worksheet code???

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("A:A")) Is Nothing Then
Else
Application.EnableEvents = False
Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Application.EnableEvents = True
End If
End Sub

Ads
  #2  
Old September 24th 07, 10:50 PM posted to microsoft.public.excel.worksheet.functions
JW[_2_]
external usenet poster
 
Posts: 638
Default Automatically alphabetize excel worksheet

On Sep 24, 5:20 pm, TanaMary >
wrote:
> Where do I enter a string in the "worksheet code" to automatically
> alphabetize my worksheet by the names in the A column. I have the string, I
> just don't know how to access the worksheet code???
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Intersect(Target, Columns("A:A")) Is Nothing Then
> Else
> Application.EnableEvents = False
> Columns("A:A").Select
> Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
> DataOption1:=xlSortNormal
> Application.EnableEvents = True
> End If
> End Sub


Right click on the sheet tab of the sheet you want to place this code
and click View Code. Then simply paste in your code.
That being said, I would probably use the code below since you don't
need an Else clause.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns("A:A")) Is Nothing Then
Application.EnableEvents = False
Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Application.EnableEvents = True
End If
End Sub

  #3  
Old September 25th 07, 02:06 PM posted to microsoft.public.excel.worksheet.functions
TanaMary
external usenet poster
 
Posts: 9
Default Automatically alphabetize excel worksheet

Thanks, JW. I tried your string but get an error when I try to put an entry
into the worksheet. Says something is "misspelled" in the argument. I
checked the "spelling" of everything but I'm not sure how to check to see if
the argument is correct (I got the original string from someone else...I'm
merely a geek; not a guru)

Thanks

"JW" wrote:

> On Sep 24, 5:20 pm, TanaMary >
> wrote:
> > Where do I enter a string in the "worksheet code" to automatically
> > alphabetize my worksheet by the names in the A column. I have the string, I
> > just don't know how to access the worksheet code???
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Intersect(Target, Columns("A:A")) Is Nothing Then
> > Else
> > Application.EnableEvents = False
> > Columns("A:A").Select
> > Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
> > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
> > DataOption1:=xlSortNormal
> > Application.EnableEvents = True
> > End If
> > End Sub

>
> Right click on the sheet tab of the sheet you want to place this code
> and click View Code. Then simply paste in your code.
> That being said, I would probably use the code below since you don't
> need an Else clause.
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Not Intersect(Target, Columns("A:A")) Is Nothing Then
> Application.EnableEvents = False
> Columns("A:A").Select
> Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
> Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
> DataOption1:=xlSortNormal
> Application.EnableEvents = True
> End If
> End Sub
>
>

  #4  
Old September 25th 07, 02:36 PM posted to microsoft.public.excel.worksheet.functions
JW[_2_]
external usenet poster
 
Posts: 638
Default Automatically alphabetize excel worksheet

The code works perfect on my end. Probably something with the way the
word wrap happens here in teh newsgroup. Try this code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns("A:A")) _
Is Nothing Then
Application.EnableEvents = False
Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Application.EnableEvents = True
End If
End Sub
TanaMary wrote:
> Thanks, JW. I tried your string but get an error when I try to put an entry
> into the worksheet. Says something is "misspelled" in the argument. I
> checked the "spelling" of everything but I'm not sure how to check to see if
> the argument is correct (I got the original string from someone else...I'm
> merely a geek; not a guru)
>
> Thanks
>
> "JW" wrote:
>
> > On Sep 24, 5:20 pm, TanaMary >
> > wrote:
> > > Where do I enter a string in the "worksheet code" to automatically
> > > alphabetize my worksheet by the names in the A column. I have the string, I
> > > just don't know how to access the worksheet code???
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Intersect(Target, Columns("A:A")) Is Nothing Then
> > > Else
> > > Application.EnableEvents = False
> > > Columns("A:A").Select
> > > Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
> > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
> > > DataOption1:=xlSortNormal
> > > Application.EnableEvents = True
> > > End If
> > > End Sub

> >
> > Right click on the sheet tab of the sheet you want to place this code
> > and click View Code. Then simply paste in your code.
> > That being said, I would probably use the code below since you don't
> > need an Else clause.
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Not Intersect(Target, Columns("A:A")) Is Nothing Then
> > Application.EnableEvents = False
> > Columns("A:A").Select
> > Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
> > Header:=xlGuess, _
> > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
> > DataOption1:=xlSortNormal
> > Application.EnableEvents = True
> > End If
> > End Sub
> >
> >


  #5  
Old September 25th 07, 09:14 PM posted to microsoft.public.excel.worksheet.functions
JW[_2_]
external usenet poster
 
Posts: 638
Default Automatically alphabetize excel worksheet

ACK!!!! Just noticed that there was a Select line in your original
code. No need for that.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Columns("A:A")) _
Is Nothing Then
Application.EnableEvents = False
Columns(1).Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Application.EnableEvents = True
End If
End Sub
JW wrote:
> The code works perfect on my end. Probably something with the way the
> word wrap happens here in teh newsgroup. Try this code:
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Not Intersect(Target, Columns("A:A")) _
> Is Nothing Then
> Application.EnableEvents = False
> Columns("A:A").Select
> Selection.Sort Key1:=Range("A1"), _
> Order1:=xlAscending, Header:=xlGuess, _
> OrderCustom:=1, MatchCase:=False, _
> Orientation:=xlTopToBottom, _
> DataOption1:=xlSortNormal
> Application.EnableEvents = True
> End If
> End Sub
> TanaMary wrote:
> > Thanks, JW. I tried your string but get an error when I try to put an entry
> > into the worksheet. Says something is "misspelled" in the argument. I
> > checked the "spelling" of everything but I'm not sure how to check to see if
> > the argument is correct (I got the original string from someone else...I'm
> > merely a geek; not a guru)
> >
> > Thanks
> >
> > "JW" wrote:
> >
> > > On Sep 24, 5:20 pm, TanaMary >
> > > wrote:
> > > > Where do I enter a string in the "worksheet code" to automatically
> > > > alphabetize my worksheet by the names in the A column. I have the string, I
> > > > just don't know how to access the worksheet code???
> > > >
> > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > If Intersect(Target, Columns("A:A")) Is Nothing Then
> > > > Else
> > > > Application.EnableEvents = False
> > > > Columns("A:A").Select
> > > > Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
> > > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
> > > > DataOption1:=xlSortNormal
> > > > Application.EnableEvents = True
> > > > End If
> > > > End Sub
> > >
> > > Right click on the sheet tab of the sheet you want to place this code
> > > and click View Code. Then simply paste in your code.
> > > That being said, I would probably use the code below since you don't
> > > need an Else clause.
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Not Intersect(Target, Columns("A:A")) Is Nothing Then
> > > Application.EnableEvents = False
> > > Columns("A:A").Select
> > > Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
> > > Header:=xlGuess, _
> > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
> > > DataOption1:=xlSortNormal
> > > Application.EnableEvents = True
> > > End If
> > > End Sub
> > >
> > >


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
alphabetize - automatically mandyjo830 Excel Worksheet Functions 2 November 14th 06 10:30 PM
Is there a way to have a excel automatically alphabetize a sheet? Mzinsser Excel Discussion (Misc queries) 2 September 18th 06 05:13 PM
need to program my lists to automatically alphabetize when new ent star*dreams Excel Worksheet Functions 0 June 1st 05 02:20 AM
How do I automatically alphabetize multiple worksheets in a singl. TS Excel Discussion (Misc queries) 2 March 19th 05 02:05 AM
how do I alphabetize items automatically in excel inspector timm Excel Worksheet Functions 1 December 18th 04 04:25 PM


All times are GMT +1. The time now is 11:26 PM.


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