ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort the Tabs (https://www.excelbanter.com/excel-programming/334326-sort-tabs.html)

A-DESIGN

Sort the Tabs
 
Hi,

Is it possible to write a VBA to sort all the TABS base on their names ?

Thanks.



Norman Jones

Sort the Tabs
 
Hi A-Design,

Try Chip Pearson's code:


Sub AlphaSortWorksheets()

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

SortDescending = False
FirstWSToSort = 1
LastWSToSort = Worksheets.Count

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



"A-Design" wrote in message
...
Hi,

Is it possible to write a VBA to sort all the TABS base on their names ?

Thanks.




Chip Pearson

Sort the Tabs
 
See www.cpearson.com/excel/sortws.htm for VBA code to do this.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"A-Design" wrote in message
...
Hi,

Is it possible to write a VBA to sort all the TABS base on
their names ?

Thanks.




A-DESIGN

Sort the Tabs
 
Thank you so much for your helps.


"Chip Pearson" wrote in message
...
See www.cpearson.com/excel/sortws.htm for VBA code to do this.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"A-Design" wrote in message
...
Hi,

Is it possible to write a VBA to sort all the TABS base on their names ?

Thanks.






A-DESIGN

Sort the Tabs
 
Thank you very much for replies.



"Chip Pearson" wrote in message
...
See www.cpearson.com/excel/sortws.htm for VBA code to do this.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"A-Design" wrote in message
...
Hi,

Is it possible to write a VBA to sort all the TABS base on their names ?

Thanks.







All times are GMT +1. The time now is 11:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com