How can I sort the sheet tabs in my workbook
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) > UCase(Sheets(iSheet).Name) Then
ActiveWorkbook.Sheets(iSheet).Move
Before:=ActiveWorkbook.Sheets(iBefore)
Exit For
End If
Next iBefore
Next iSheet
End Sub
--
Don Guillett
SalesAid Software
[email protected]
"Techtrainer" <[email protected]> wrote in message
news:[email protected]...
> How can I sort the sheet tabs in my workbook
"Techtrainer" wrote:
> 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
Before:=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
"Don Guillett" wrote:
> 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) > UCase(Sheets(iSheet).Name) Then
> ActiveWorkbook.Sheets(iSheet).Move
> Before:=ActiveWorkbook.Sheets(iBefore)
> Exit For
> End If
> Next iBefore
> Next iSheet
> End Sub
>
> --
> Don Guillett
> SalesAid Software
> [email protected]
> "Techtrainer" <[email protected]> wrote in message
> news:[email protected]...
> > How can I sort the sheet tabs in my workbook
>
>
>
The lines
ActiveWorkbook.Sheets(iSheet).Move
Before:=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
"Techtrainer" <[email protected]> wrote in
message
news:[email protected]...
>
>
> "Techtrainer" wrote:
>
>> 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
> Before:=ActiveWorkbook.Sheets(iBefore)
>
> Compiler doesn't seem to like :=
Thanks Chip!
"Chip Pearson" wrote:
> The lines
>
> ActiveWorkbook.Sheets(iSheet).Move
> Before:=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
>
>
>
> "Techtrainer" <[email protected]> wrote in
> message
> news:[email protected]...
> >
> >
> > "Techtrainer" wrote:
> >
> >> 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
> > Before:=ActiveWorkbook.Sheets(iBefore)
> >
> > Compiler doesn't seem to like :=
>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks