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
- 2888 reads
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago