Microsoft Office Tutorials and References
In Depth Information
Figure 17-8. Augmenting the DataSheet worksheet
' Fill array with worksheet names
For i = 1 To cSheets
sSheets(i) = wb.Sheets(i).Name
Next
' Create new sheet and put names in first column
Set ws = wb.Worksheets.Add
For i = 1 To cSheets
ws.Cells(i, 1).Value = sSheets(i)
Next
' Sort column
ws.Columns(1).Sort Key1:=ws.Columns(1), _
Order1:=xlAscending
' Refill array
For i = 1 To cSheets
sSheets(i) = ws.Cells(i, 1).Value
Next
' Delete extraneous sheet
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
' Reorder sheets by moving each one to the end
For i = 1 To cSheets
wb.Sheets(sSheets(i)).Move After:=wb.Sheets(cSheets)
Next
End Sub
Once the code is inserted, you can save the SRXUtils.xls workbook as an add-in. Don't forget to
unload the add-in first, or Excel will complain.
Search JabSto ::




Custom Search