XLA routines: EE_RearrangeSheetsAlphabetic
EE_RearrangeSheetsAlphabetic is useful to use at the end of your procedure when you have created sheets all over the place and want them rearraged alphabetically.
Sub EE_RearrangeSheetsAlphabetic(Optional SortDescending As Boolean = False) '> - takes a boolean to tell whether ascending or descending '> - rearranges sheets Dim intLoopFull As Integer Dim intLoopInner As Integer Dim wbk As Workbook 'http://excelexperts.com/xla-routines-eerearrangesheetsalphabetic Set wbk = ThisWorkbook For intLoopInner = 1 To wbk.Worksheets.Count For intLoopFull = intLoopInner To wbk.Worksheets.Count If SortDescending = True Then If UCase(wbk.Worksheets(intLoopFull).Name) > UCase(wbk.Worksheets(intLoopInner).Name) Then wbk.Worksheets(intLoopFull).Move Before:=wbk.Worksheets(intLoopInner) End If Else If UCase(wbk.Worksheets(intLoopFull).Name) < UCase(wbk.Worksheets(intLoopInner).Name) Then wbk.Worksheets(intLoopFull).Move Before:=wbk.Worksheets(intLoopInner) End If End If Next intLoopFull Next intLoopInner Set wbk = Nothing End Sub
»
- Nick's blog
- Login or register to post comments
- 2922 reads
Recent comments
5 years 41 weeks ago
6 years 27 weeks ago
6 years 39 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 48 weeks ago
7 years 4 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago