Vba add worksheet and rename worksheet in Excel
To do it in Excel, here is the answer:
- Option Explicit
- Sub AddAndNameWorkSheet()
- ActiveSheet.Name = "New Sheet"
- End Sub
a) Line 3 - Adds a WorkSheet. If position of the sheet is to be specified After or Before sheet name could be used (ThisWorkBook.Sheets.Add After:=Sheet1 or ThisWorkBook.Sheets.Add Before:=Sheet3)
b) Line 4 - Since by default after addition of sheet, the newly created sheet is activated, ActiveSheet object could be used to rename the newly created WorkSheet.