In this topic we learn how to add worksheet in excel workbook by below different multiple method.
- Add new sheets in workbook
- Add new sheets before/after define sheet
- Add new sheets based on cell value
- Validate of sheets
First we go to next option we have to read Syntex
"expression.Add (Before, After, Count, Type)"
Let's first take detail about syntex
Expression A variable that represent a sheets object
Add new sheet in workbook :-
Open excel workbook and go to Developer option and copy below code into module
Note:- we have given name "Sh_add" and you can give name your accordingly
1.Option
sub sh_add()
worksheets.add
End sub
Output :- This is simple way to add new workbook sheet. when you run this code then by default new sheet will add in active workbook
2.Option
Sub sh_Add()
Dim As Workbook
Set wb = ThisWorkbook 'Enter workbook in which you want add new worksheet"
wb.Worksheets.Add
End Sub
Output :- sometime we open multiple workbook and run macro then new sheet add in active workbook.
So. if you want to add new sheets in particular workbook then we have to declare workbook.
In above code we have declared "wb" as "This workbook".
Here you can put specific excel workbook name in which you want to add new sheet
3. Option
0 Comments