I have a Workbook with a number of Worksheets, currently 6 but this will increase in the future. The Tabs / Worksheet names are in Alphabetical order, with a "Template" sheet at the end.
I am cloning that Template sheet & creating a new Worksheet with the name specified by the user, but how can I insert it into the Workbook so it is in the correct position Alphabetically ?
Best How To :
I understand the workbook is already sorted and that a new sheet must be inserted in the alphabetical order, copied from a template sheet. The following code will do that:
Sub InsertSheet(name As String)
For i = 1 To ActiveWorkbook.Sheets.Count
If ActiveWorkbook.Sheets(i).name >= name Then
ActiveSheet.name = name ' can fail if sheet already exists