![]() |
Sorting sheets
Hi All,
I have a workbook with several sheets. Each sheet is named by an employee ID number. I want to sort the sheets according to the position of each group of employee. Is there a way to sort sheets? (A-Z or customize) Thanks in advance |
Sorting sheets
Sub sortsheets()
'Re-Sort sheet names ' Thanks to McRitchie & Bill Manville Dim iSheet As Integer Dim iBefore As Integer For iSheet = 1 To Worksheets.Count For iBefore = 1 To iSheet - 1 If UCase(Sheets(iBefore).Name) UCase(Sheets(iSheet).Name) Then Sheets(iSheet).Move befo=Sheets(iBefore) Exit For End If Next iBefore Next iSheet End Sub HTH -- AP "Lp12" a écrit dans le message de news: ... Hi All, I have a workbook with several sheets. Each sheet is named by an employee ID number. I want to sort the sheets according to the position of each group of employee. Is there a way to sort sheets? (A-Z or customize) Thanks in advance |
Sorting sheets
That was an alpha sort.
For a numeric sort: '------------------------------------------------------------------------------- Sub sortsheets() 'Re-Sort sheet names ' Thanks to McRitchie & Bill Manville Dim iSheet As Integer Dim iBefore As Integer For iSheet = 1 To Worksheets.Count For iBefore = 1 To iSheet - 1 If CInt(Sheets(iBefore).Name) CInt(Sheets(iSheet).Name) Then Sheets(iSheet).Move befo=Sheets(iBefore) Exit For End If Next iBefore Next iSheet End Sub |
Sorting sheets
You need to use a VBA procedure. See
www.cpearson.com/excel/sortws.htm for example code. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Lp12" wrote in message ... Hi All, I have a workbook with several sheets. Each sheet is named by an employee ID number. I want to sort the sheets according to the position of each group of employee. Is there a way to sort sheets? (A-Z or customize) Thanks in advance |
All times are GMT +1. The time now is 02:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com