PC Review


Reply
Thread Tools Rate Thread

Alphabetizing Worksheets

 
 
geigersc
Guest
Posts: n/a
 
      24th Feb 2008
I have used a program by someone else that is supposed to alphabetize my
worksheets. Unfortunately I'm not sure how to debug the code. This is a
portion of what I have:

'''''''''''''''''''''''''''''''''''''''''''''''
' If First and Last are both 0, sort all sheets.
''''''''''''''''''''''''''''''''''''''''''''''
If (FirstToSort = 0) And (LastToSort = 0) Then
FirstToSort = 1
LastToSort = WB.Worksheets.Count
Else
'''''''''''''''''''''''''''''''''''''''
' More than one sheet selected. We
' can sort only if the selected
' sheet are adjacent.
'''''''''''''''''''''''''''''''''''''''
B = TestFirstLastSort(FirstToSort, LastToSort, ErrorText)
If B = False Then
SortWorksheetsByName = False
Exit Function
End If
End If

When I "debug" I get the following message:

Compile Error:
Sub or Function not defined

Do you need to know more to help me? I'm a little clueless, to say the
least on this. I've tried looking at different sites, but without totally
understanding the coding, I'm not sure what I'm looking for, or how to cure
the issue.

Thank you for your help... in advance. A lot of you guys/gals on here that
help are VERY much appreciated.
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      24th Feb 2008
http://www.cpearson.com/excel/sortws.aspx
--
Gary''s Student - gsnu200770
 
Reply With Quote
 
johnmanivong@earthlink.net
Guest
Posts: n/a
 
      24th Feb 2008
On Feb 24, 6:52*am, geigersc <geige...@discussions.microsoft.com>
wrote:
> I have used a program by someone else that is supposed to alphabetize my
> worksheets. *Unfortunately I'm not sure how to debug the code. *This is a
> portion of what I have:
>
> '''''''''''''''''''''''''''''''''''''''''''''''
> ' If First and Last are both 0, sort all sheets.
> ''''''''''''''''''''''''''''''''''''''''''''''
> If (FirstToSort = 0) And (LastToSort = 0) Then
> * * FirstToSort = 1
> * * LastToSort = WB.Worksheets.Count
> Else
> * * '''''''''''''''''''''''''''''''''''''''
> * * ' More than one sheet selected. We
> * * ' can sort only if the selected
> * * ' sheet are adjacent.
> * * '''''''''''''''''''''''''''''''''''''''
> * * B = TestFirstLastSort(FirstToSort, LastToSort, ErrorText)
> * * If B = False Then
> * * * * SortWorksheetsByName = False
> * * * * Exit Function
> * * End If
> End If
>
> When I "debug" I get the following message:
>
> Compile Error:
> Sub or Function not defined
>
> Do you need to know more to help me? *I'm a little clueless, to say the
> least on this. *I've tried looking at different sites, but without totally
> understanding the coding, I'm not sure what I'm looking for, or how to cure
> the issue.
>
> Thank you for your help... in advance. *A lot of you guys/gals on here that
> help are VERY much appreciated.


Try this

Option Explicit

--------------------------------------------------------------------------------

Sub SortingWks()
Dim i As Long
Dim j As Long
For i = 1 To Worksheets.Count
j = i
Do While j > 1
If Worksheets(j).Name < Worksheets(j - 1).Name Then
Worksheets(j).Move Before:=Worksheets(j - 1)
End If
j = j - 1
Loop
Next
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
Re: Alphabetizing Worksheets Jim Cone Microsoft Excel Misc 0 29th Dec 2006 07:09 PM
Alphabetizing mulitiple worksheets in Excel 2003? =?Utf-8?B?RGVlbmEgYXQgRENIIEZE?= Microsoft Excel Misc 2 13th Jun 2006 04:24 PM
Alphabetizing Worksheets =?Utf-8?B?RGF2ZQ==?= Microsoft Excel Worksheet Functions 3 16th Mar 2006 06:56 PM
Alphabetizing Worksheets Di Microsoft Excel Worksheet Functions 2 5th Apr 2004 06:09 PM
Alphabetizing worksheets ME Microsoft Excel Worksheet Functions 4 18th Mar 2004 07:45 PM


Features
 

Advertising
 

Newsgroups
 


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