Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Stuart
 
Posts: n/a
Default how can i re-sort multiple worksheets into alphabetical order

I have a barrowload of multiple worksheets, but now client wants them in a
different order, is there, to save time, any way that Excel can re-sort them
in Alphabetical order.
  #2   Report Post  
Niek Otten
 
Posts: n/a
Default

http://www.cpearson.com/excel/sortws.htm

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Stuart" wrote in message
...
I have a barrowload of multiple worksheets, but now client wants them in a
different order, is there, to save time, any way that Excel can re-sort
them
in Alphabetical order.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default how can i re-sort multiple worksheets into alphabetical order

Public Sub SortSheets()

Dim currentUpdating As Boolean
currentUpdating = Application.ScreenUpdating

Application.ScreenUpdating = False

For Each xlSheet In ActiveWorkbook.Worksheets
For Each xlSheet2 In ActiveWorkbook.Worksheets
If LCase(xlSheet2.Name) < LCase(xlSheet.Name) Then
xlSheet2.Move befo=xlSheet
End If
Next xlSheet2
Next xlSheet

Application.ScreenUpdating = currentUpdating

End Sub

"Niek Otten" wrote:

http://www.cpearson.com/excel/sortws.htm

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Stuart" wrote in message
...
I have a barrowload of multiple worksheets, but now client wants them in a
different order, is there, to save time, any way that Excel can re-sort
them
in Alphabetical order.




  #4   Report Post  
Senior Member
 
Location: Hyderabad
Posts: 237
Thumbs up

Quote:
Originally Posted by Stuart View Post
I have a barrowload of multiple worksheets, but now client wants them in a
different order, is there, to save time, any way that Excel can re-sort them
in Alphabetical order.
try this code,

Copy the code below.
Open the Excel file in which you want to use the code.
Hit Alt+F11 to open the Visual Basic Editor (VBE) window.
From the menu, choose Insert-Module.
Paste the code into the code window at right.
Save the file and close the VBE.


'bala sesharao edited to sort worksheets
Option Explicit

Sub SortWorksheets()

Dim N As Integer
Dim M As Integer
Dim FirstWSToSort As Integer
Dim LastWSToSort As Integer
Dim SortDescending As Boolean

SortDescending = False

If ActiveWindow.SelectedSheets.Count = 1 Then

'Change the 1 to the worksheet you want sorted first
FirstWSToSort = 1
LastWSToSort = Worksheets.Count
Else
With ActiveWindow.SelectedSheets
For N = 2 To .Count
If .Item(N - 1).Index < .Item(N).Index - 1 Then
MsgBox "You cannot sort non-adjacent sheets"
Exit Sub
End If
Next N
FirstWSToSort = .Item(1).Index
LastWSToSort = .Item(.Count).Index
End With
End If

For M = FirstWSToSort To LastWSToSort
For N = M To LastWSToSort
If SortDescending = True Then
If UCase(Worksheets(N).Name) UCase(Worksheets(M).Name) Then
Worksheets(N).Move Befo=Worksheets(M)
End If
Else
If UCase(Worksheets(N).Name) < UCase(Worksheets(M).Name) Then
Worksheets(N).Move Befo=Worksheets(M)
End If
End If
Next N
Next M

End Sub
__________________
Thanks
Bala
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
Need to have multiple worksheets use a single worksheet storm5527 Excel Worksheet Functions 1 April 22nd 05 11:25 AM
fax multiple worksheets volleyman Excel Worksheet Functions 0 March 30th 05 05:51 PM
Extracting data from multiple worksheets into a list mnirula Excel Worksheet Functions 16 February 25th 05 08:52 PM
adding certain cells in multiple worksheets in multiple workbooks Stephen via OfficeKB.com Excel Worksheet Functions 1 February 4th 05 08:31 PM
Countif with multiple criteria and multiple worksheets JJ Excel Worksheet Functions 1 December 28th 04 06:37 PM


All times are GMT +1. The time now is 12:55 AM.

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

About Us

"It's about Microsoft Excel"