How can I sort the sheet tabs in my workbook
try
Sub SortALLSheetsbyName() 'McRitchie
'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) gt; UCase(Sheets(iSheet).Name) Then
ActiveWorkbook.Sheets(iSheet).Move
Befo=ActiveWorkbook.Sheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet
End Sub
--
Don Guillett
SalesAid Software
quot;Techtrainerquot; gt; wrote in message
news
gt; How can I sort the sheet tabs in my workbook
quot;Techtrainerquot; wrote:
gt; How can I sort the sheet tabs in my workbook
Thanks for the response!
I am getting an error thougn on the following line
ActiveWorkbook.Sheets(iSheet).Move
Befo=ActiveWorkbook.Sheets(iBefore)
Compiler doesn't seem to like :=
Thank you!!
I wrote back about an error I was getting but it was just a syntax problem.
I got it corrected and it works fine.
Thank You !!!
Bill vernola
quot;Don Guillettquot; wrote:
gt; try
gt;
gt; Sub SortALLSheetsbyName() 'McRitchie
gt; 'sort sheets within a workbook in Excel 7 -- Bill Manville
gt; 'modified to sort all sheets instead of just worksheets
gt; Dim iSheet As Integer, iBefore As Integer
gt; For iSheet = 1 To ActiveWorkbook.Sheets.Count
gt; Sheets(iSheet).Visible = True
gt; For iBefore = 1 To iSheet - 1
gt; If UCase(Sheets(iBefore).Name) gt; UCase(Sheets(iSheet).Name) Then
gt; ActiveWorkbook.Sheets(iSheet).Move
gt; Befo=ActiveWorkbook.Sheets(iBefore)
gt; Exit For
gt; End If
gt; Next iBefore
gt; Next iSheet
gt; End Sub
gt;
gt; --
gt; Don Guillett
gt; SalesAid Software
gt;
gt; quot;Techtrainerquot; gt; wrote in message
gt; news
gt; gt; How can I sort the sheet tabs in my workbook
gt;
gt;
gt;
The lines
ActiveWorkbook.Sheets(iSheet).Move
Befo=ActiveWorkbook.Sheets(iBefore)
should all be on one line in the code module.
See also www.cpearson.com/excel/sortws.htm for a procedure to
sort worksheets.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
quot;Techtrainerquot; gt; wrote in
message
...
gt;
gt;
gt; quot;Techtrainerquot; wrote:
gt;
gt;gt; How can I sort the sheet tabs in my workbook
gt;
gt; Thanks for the response!
gt; I am getting an error thougn on the following line
gt; ActiveWorkbook.Sheets(iSheet).Move
gt; Befo=ActiveWorkbook.Sheets(iBefore)
gt;
gt; Compiler doesn't seem to like :=
Thanks Chip!
quot;Chip Pearsonquot; wrote:
gt; The lines
gt;
gt; ActiveWorkbook.Sheets(iSheet).Move
gt; Befo=ActiveWorkbook.Sheets(iBefore)
gt;
gt; should all be on one line in the code module.
gt;
gt; See also www.cpearson.com/excel/sortws.htm for a procedure to
gt; sort worksheets.
gt;
gt; --
gt; Cordially,
gt; Chip Pearson
gt; Microsoft MVP - Excel
gt; Pearson Software Consulting, LLC
gt; www.cpearson.com
gt;
gt;
gt;
gt; quot;Techtrainerquot; gt; wrote in
gt; message
gt; ...
gt; gt;
gt; gt;
gt; gt; quot;Techtrainerquot; wrote:
gt; gt;
gt; gt;gt; How can I sort the sheet tabs in my workbook
gt; gt;
gt; gt; Thanks for the response!
gt; gt; I am getting an error thougn on the following line
gt; gt; ActiveWorkbook.Sheets(iSheet).Move
gt; gt; Befo=ActiveWorkbook.Sheets(iBefore)
gt; gt;
gt; gt; Compiler doesn't seem to like :=
gt;
gt;
gt;
- Sep 23 Tue 2008 20:46
Can you sort sheet tabs in a workbook
close
全站熱搜
留言列表
發表留言