PC Review


Reply
Thread Tools Rate Thread

Automatically alphabetize excel worksheet

 
 
=?Utf-8?B?VGFuYU1hcnk=?=
Guest
Posts: n/a
 
      24th Sep 2007
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

 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      24th Sep 2007
On Sep 24, 5:20 pm, TanaMary <TanaM...@discussions.microsoft.com>
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

 
Reply With Quote
 
=?Utf-8?B?VGFuYU1hcnk=?=
Guest
Posts: n/a
 
      25th Sep 2007
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 <TanaM...@discussions.microsoft.com>
> 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
>
>

 
Reply With Quote
 
JW
Guest
Posts: n/a
 
      25th Sep 2007
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 <TanaM...@discussions.microsoft.com>
> > 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
> >
> >


 
Reply With Quote
 
JW
Guest
Posts: n/a
 
      25th Sep 2007
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 <TanaM...@discussions.microsoft.com>
> > > 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
> > >
> > >


 
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
How to Alphabetize automatically ? Curious Microsoft Word Document Management 0 27th Nov 2007 05:15 PM
How can I alphabetize my worksheet? =?Utf-8?B?Q2hhbmll?= Microsoft Excel Misc 3 23rd Nov 2006 07:00 PM
alphabetize - automatically mandyjo830 Microsoft Excel Worksheet Functions 2 14th Nov 2006 09:30 PM
Is there a way to have a excel automatically alphabetize a sheet? =?Utf-8?B?TXppbnNzZXI=?= Microsoft Excel Misc 2 18th Sep 2006 05:13 PM
how do I alphabetize items automatically in excel =?Utf-8?B?aW5zcGVjdG9yIHRpbW0=?= Microsoft Excel Worksheet Functions 1 18th Dec 2004 03:25 PM


Features
 

Advertising
 

Newsgroups
 


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