LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Copy Worksheet Not the Macros

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros for Consolidating data in worksheet 1 on worksheet 2 Omokehinde Excel Programming 1 March 4th 12 01:45 PM
Move/Copy Worksheet with Macros Hansplay Excel Discussion (Misc queries) 2 October 9th 09 05:51 PM
Mastersheet to Worksheet data copy - macros? DCT Mvumi School Excel Discussion (Misc queries) 1 June 4th 09 12:10 PM
Macros: can you copy macros from one doc to another? Roady Excel Discussion (Misc queries) 1 June 12th 08 05:47 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM


All times are GMT +1. The time now is 09:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"