Got any Excel/VBA Questions? Free Excel Help.
There are occasions where adding a new Worksheet to an Excel Workbook should be added in a number sequence. For example, you may need to add Worksheets, name them in a numeric order and have the Worksheets in the correct numeric position. The code below will do this
Sub AddNumberSequence() Dim wSheet As Worksheet Dim lNum As Long Dim lIndex As Long For Each wSheet In Worksheets If IsNumeric(wSheet.Name) Then lNum = wSheet.Name + 1 lIndex = wSheet.Index End If Next wSheet If lNum <> 0 Then Worksheets.Add After:=Worksheets(lIndex) ActiveSheet.Name = lNum End If End Sub
Microsoft and Microsoft Excel are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft.
Add Excel Worksheets in Month/Monthly Order |
Free Training Course: Lesson 1 - Excel Fundamentals
See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions. Svensk casino guide https://videospelautomater.com/svenska-casinon/