Hi, I am a beginner. I want to add few sheet to an excel files and at the same time rename them. Kindly also provide code to delete a sheet from a workbook.
Sheets can be referred to by their position in the workbook (Sheets(1), Sheets(2), Sheets(Sheets.Count) for the last sheet, etc.) or by their name - Sheets("My Sheet") They can also be referred to by a variable that represents a Name or number.
Here are some examples....
Sub SheetStuff() 'Add a sheet as the last sheet Sheets.Add After:=Sheets(Sheets.Count) 'Add a sheet as the second sheet Sheets.Add Before:=Sheets(3) 'Name / Rename Sheet2 Sheets(2).Name = "My Second Sheet" 'Delete the first sheet Sheets(1).Delete 'Delete a sheet by name Sheets("My Second Sheet").Delete 'Delete Sheet 3 by variable varSht = 3 Sheets(varSht).Delete End SubClick Here Before Posting Data or VBA Code ---> How To Post Data or Code.
