Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting the order of sheets by the name


Hi

Is there a way to sort the order of the sheet, depending on the name of
the sheets?

i.e.


I have several workbooks with names like "Sch 13", "Sch 8A" and "Sch
8B".
I would like a way to sort these by name or the number they contain.


Thanks


--
Ctech
------------------------------------------------------------------------
Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=488136

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sorting the order of sheets by the name

Hi Ctech,

Try Chip Pearson's procedu

'==============
Sub SortWorksheets()
'Chip Pearson

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
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
'<<==============



--

---
Regards,
Norman



"Ctech" wrote in
message ...

Hi

Is there a way to sort the order of the sheet, depending on the name of
the sheets?

i.e.


I have several workbooks with names like "Sch 13", "Sch 8A" and "Sch
8B".
I would like a way to sort these by name or the number they contain.


Thanks


--
Ctech
------------------------------------------------------------------------
Ctech's Profile:
http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=488136



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sorting the order of sheets by the name

Hi Ctech,

I should have additionally suggested that you visit Chip Pearson's Sorting
Worksheets page for additional information and material.

---
Regards,
Norman

"Ctech" wrote in
message ...

Hi

Is there a way to sort the order of the sheet, depending on the name of
the sheets?

i.e.


I have several workbooks with names like "Sch 13", "Sch 8A" and "Sch
8B".
I would like a way to sort these by name or the number they contain.


Thanks


--
Ctech
------------------------------------------------------------------------
Ctech's Profile:
http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=488136



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting the order of sheets by the name


Do you have a link?


--
Ctech
------------------------------------------------------------------------
Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=488136

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sorting the order of sheets by the name

Hi Ctech,

My apologies - I noticed the missing link and was sure that I included it in
a follow-up post.

The link is:

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

---
Regards,
Norman



"Ctech" wrote in
message ...

Do you have a link?


--
Ctech
------------------------------------------------------------------------
Ctech's Profile:
http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=488136



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
Excel Sorting Order DoxieLvr Excel Discussion (Misc queries) 3 December 12th 09 01:29 AM
Customized Sorting Order Augustflowers New Users to Excel 1 July 19th 07 03:10 PM
sorting data in order ceemo Excel Worksheet Functions 1 July 6th 05 12:13 PM
sorting in order ceemo Excel Worksheet Functions 2 June 30th 05 05:48 PM
sorting in order ceemo Excel Worksheet Functions 0 June 30th 05 01:20 PM


All times are GMT +1. The time now is 10:02 PM.

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"