Code to create atbs in excel sheet

D

deepa prabhakar

My doubt is this.
I need to write a program to open an excel sheet and copy 3 excel sheet
into single .xls file which should contain 3 excel sheets.How do i
proceed?
 
M

mrice

To create your new workbook with three sheets you can use

Sub Test()
Workbooks.Add
If ActiveWorkbook.Sheets.Count < 3 Then
For N = 1 To 3 - ActiveWorkbook.Sheets.Count
Sheets.Add
Next N
ElseIf ActiveWorkbook.Sheets.Count > 3 Then
Application.DisplayAlerts = False
For N = 1 To ActiveWorkbook.Sheets.Count - 3
Sheets(1).Delete
Next N
Application.DisplayAlerts = True
End If
End Su
 
Top