M
micheldevon
I'm looking to copy a worksheet from one Workbook to a new workbook,
but I don't want the Macros, Code or Forms to copy. Only the Worksheet
Data. Any ideas?
This is the code I'm currently using to create the new workbook.
Sub CopySheets()
Application.ScreenUpdating = False
Dim ws As Worksheet, fileDate As String, bFirst As Boolean, wbkNew
As Workbook
Application.DisplayAlerts = False
actwb = ActiveWorkbook.Name
fileDate = Format(Date, "mm-dd-yy")
filenm = (fileDate) & ".xls" 'assign the new workbooks names
bFirst = True
For Each ws In ThisWorkbook.Worksheets
Select Case ws.Name
Case "CHIP RESPONSE LOG", "DocuGrab", "CPC PROD LOG",
"MODIFIER_GRID", "TCR PASS", "TCR DENIAL"
'these are the sheets names which shouldn't be copied
Case Else
If bFirst = True Then
ws.Copy
Set wbkNew = ActiveWorkbook
Set VBComps = ActiveWorkbook.VBProject.VBComponents
bFirst = False
'with the first sheet copied, create a new workbook
Else
ws.Copy After:=wbkNew.Sheets(wbkNew.Sheets.Count)
'add subsequent copies to the new workbook
With ActiveWorkbook.VBProject
End If
End Select
Next ws
wbkNew.SaveAs Filename:=(fileDate) & ".xls"
wbkNew.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
but I don't want the Macros, Code or Forms to copy. Only the Worksheet
Data. Any ideas?
This is the code I'm currently using to create the new workbook.
Sub CopySheets()
Application.ScreenUpdating = False
Dim ws As Worksheet, fileDate As String, bFirst As Boolean, wbkNew
As Workbook
Application.DisplayAlerts = False
actwb = ActiveWorkbook.Name
fileDate = Format(Date, "mm-dd-yy")
filenm = (fileDate) & ".xls" 'assign the new workbooks names
bFirst = True
For Each ws In ThisWorkbook.Worksheets
Select Case ws.Name
Case "CHIP RESPONSE LOG", "DocuGrab", "CPC PROD LOG",
"MODIFIER_GRID", "TCR PASS", "TCR DENIAL"
'these are the sheets names which shouldn't be copied
Case Else
If bFirst = True Then
ws.Copy
Set wbkNew = ActiveWorkbook
Set VBComps = ActiveWorkbook.VBProject.VBComponents
bFirst = False
'with the first sheet copied, create a new workbook
Else
ws.Copy After:=wbkNew.Sheets(wbkNew.Sheets.Count)
'add subsequent copies to the new workbook
With ActiveWorkbook.VBProject
End If
End Select
Next ws
wbkNew.SaveAs Filename:=(fileDate) & ".xls"
wbkNew.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub