Sorting Worksheets

  • Thread starter Thread starter Justin
  • Start date Start date
J

Justin

Is there a way to sort your worksheets within a excel File
for exsmaple I have A-T and I want it to go T-A is there a
better way to do this then moving the worksheets by hand.

Thanks a bunch.
 
There is probably a way to do this with VBA. Post this question on the
excel.programming forum for VBA help.

- John
 
As a modification of SortALLsheets that you can find
in buildtoc.htm or buildtoc2.htm on my site, this should work:
(as if hopefully)

Sub Reverse_SortALLSheets()
'sort sheets within a workbook in Excel 7 -- Bill Manville
'modified to sort all sheets instead of just worksheets
'called by BuildTOC macro you can use another macro...
Dim iSheet As Integer, iAfter As Integer
For iSheet = 1 To ActiveWorkbook.Sheets.Count
Sheets(iSheet).Visible = True
For iAfter = 1 To iSheet - 1
If UCase(Sheets(iAfter).Name) < UCase(Sheets(iSheet).Name) Then
ActiveWorkbook.Sheets(iSheet).Move Before:=ActiveWorkbook.Sheets(iAfter)
Exit For
End If
Next iAfter
Next iSheet
End Sub

To install and run macro see
http://www.mvps.org/dmcritchie/excel/getstarted.htm
--
 
Back
Top