Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheets in alphabetical order
I am using Excel 97.
I want to sort worksheets in a workbook so that they are in alphabetical order. Can anyone asist me with some code? Thanks Mark |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheets in alphabetical order
Sub SortALLSheets()
'sort sheets within a workbook in Excel 7 -- Bill Manville 'modified to sort all sheets instead of just worksheets Dim iSheet As Integer, iBefore As Integer For iSheet = 1 To ActiveWorkbook.Sheets.Count Sheets(iSheet).Visible = True For iBefore = 1 To iSheet - 1 If UCase(Sheets(iBefore).Name) UCase(Sheets(iSheet).Name) Then ActiveWorkbook.Sheets(iSheet).Move Befo=ActiveWorkbook.Sheets(iBefore) Exit For End If Next iBefore Next iSheet End Sub Rgds, Andy On the stereo this week ; Albinoni, Samuel Barber, Nirvana, Sinead O'Connor |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheets in alphabetical order
Hi Mark, For sorting sheet tab copy below code to your standard module & run macro sortsheet. --------------------------------------------------- Sub Sortsheet() Quicksortsheets ' without arguments for ascending 'Quicksortsheets "D" ' with arguments for descending end sub Sub QuickSortSheets(Optional SortOrder) Dim i As Long Dim j As Long Dim SheetsCount As Long Dim FirstSheet As String Dim NextSheet As String Dim LValue As String Dim HValue As String Dim VTemp As String Application.ScreenUpdating = 0 SheetsCount = Worksheets.Count For i = 1 To SheetsCount \ 2 FirstSheet = Worksheets(i).Name LValue = FirstSheet HValue = FirstSheet For j = i To SheetsCount - 1 NextSheet = Worksheets(j + 1).Name If LValue NextSheet Then LValue = NextSheet If HValue < NextSheet Then HValue = NextSheet Next If IsMissing(SortOrder) Then Else VTemp = LValue LValue = HValue HValue = VTemp End If If LValue < FirstSheet Then Worksheets (LValue).Move befo=Worksheets(i) If HValue < Worksheets(SheetsCount).Name Then Worksheets(HValue).Move after:=Worksheets(SheetsCount) SheetsCount = SheetsCount - 1 Next Application.ScreenUpdating = 1 End Sub You can also see below sites www.cpearson.com/excel/sortws.htm http://www.mvps.org/dmcritchie/excel...#sortallsheets Regards, Shah Shailesh http://members.lycos.co.uk/shahweb/ *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Worksheets in alphabetical order
Hi Mark,
Here is a simple code I wrote. Please try this. Sub WorksheetSort() Dim intC1 As Long, intC2 As Integer For intC1 = 1 To Sheets.Count For intC2 = 1 To Sheets.Count - 1 If Sheets(intC2).Name Sheets(intC2 + 1).Name Then Sheets(intC2).Move after:=Sheets(intC2 + 1) End If Next intC2, intC1 End Sub -- Kind Regards Colo /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ Colo of 'The Road of The Cell Masters' :) URL:http://www.interq.or.jp/sun/puremis/...astersLink.htm /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ "Mark" wrote in message ... I am using Excel 97. I want to sort worksheets in a workbook so that they are in alphabetical order. Can anyone asist me with some code? Thanks Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to arrange worksheets in alphabetical order? | Excel Worksheet Functions | |||
How to arrange worksheets in alphabetical order? | Excel Worksheet Functions | |||
How to put worksheets in Alphabetical order? | Excel Discussion (Misc queries) | |||
How do I put worksheets in alphabetical order | New Users to Excel | |||
How do I put worksheets in alphabetical order | Excel Worksheet Functions |