Coping a sheet

J

James

Hello

Can you tell me what the VBA code is for copying a sheet out of one book into a new one

Thanks in advance
James
 
R

Ron de Bruin

Hi James

You can use
Activesheet.Copy or Sheets("Sheet3").Copy

To create a new workbook with only that sheet


Or this

This example will copy the first sheet of the activeworkbook.
It open the file C:\test.xls and paste the sheet.
After that it will save/close the file C:\test.xls

Sub test()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Application.ScreenUpdating = False
Set Wb1 = ActiveWorkbook
Set Wb2 = Workbooks.Open("C:\test.xls")
Wb1.Worksheets(1).Copy after:= _
Wb2.Sheets(Wb2.Sheets.Count)
Wb2.Close True
Application.ScreenUpdating = True
End Sub
 
Top