Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy for Backup Purpose.

Hi, A Happy New Year Greetings to everybody here.

I hope someone here can help me for this task.
I have a file say "Data.xls" which has 25 sheets under different names.
I like to copy all the 25 sheets of "Data.xls" to a new file say
"Backup.xls" which contain only the values excluding all the formulas
and macros.

Any kind help is appreciated.
Thank you.

Michael


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Copy for Backup Purpose.

Michael,

Sub testit()
Dim wkbSource As Workbook, wkbDest As Workbook, wks As Worksheet
Dim blnFirstWks As Boolean

Set wkbSource = Workbooks.Open("C:\data.xls")

blnFirstWks = True
For Each wks In wkbSource.Worksheets
If blnFirstWks Then
wks.Copy
Set wkbDest = ActiveWorkbook
blnFirstWks = False
Else
wks.Copy After:=wkbDest.Worksheets(wkbDest.Worksheets.Count )
End If
With wkbDest.Worksheets(wkbDest.Worksheets.Count).Cells
.Copy
.PasteSpecial Paste:=xlValues
.Cells(1, 1).Select
End With
Next
Application.CutCopyMode = False

wkbDest.SaveAs "C:\Backup.xls"

wkbSource.Close False
wkbDest.Close False
End Sub

Rob


"Michael168" wrote in message
...
Hi, A Happy New Year Greetings to everybody here.

I hope someone here can help me for this task.
I have a file say "Data.xls" which has 25 sheets under different names.
I like to copy all the 25 sheets of "Data.xls" to a new file say
"Backup.xls" which contain only the values excluding all the formulas
and macros.

Any kind help is appreciated.
Thank you.

Michael


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy for Backup Purpose.

Believe Rob's excellent approach will leave code in Sheet Modules. If this
is a problem for you, then
Here is some code previously posted by Jim Rech that could be used to remove
that code after you create the workbook with Rob's code.

http://groups.google.com/groups?thre...%40tkmsftngp07

''Needs a reference to the VB Extensibility library set
'Removes from active workbook all:
''Regular modules
''Class modules
''Userforms
''Code in sheet and workbook modules
''Non built-in references
''Excel 4 macro sheets
''Dialog sheets
Sub RemoveAllCode()
Dim VBComp As Object, AllComp As Object, ThisProj As Object
Dim ThisRef As Reference, WS As Worksheet, DLG As DialogSheet
Set ThisProj = ActiveWorkbook.VBProject
Set AllComp = ThisProj.VBComponents
For Each VBComp In AllComp
With VBComp
Select Case .Type
Case vbext_ct_StdModule, vbext_ct_ClassModule, _
vbext_ct_MSForm
AllComp.Remove VBComp
Case vbext_ct_Document
.CodeModule.DeleteLines 1, .CodeModule.CountOfLines
End Select
End With
Next
For Each ThisRef In ThisProj.References
If Not ThisRef.BuiltIn Then ThisProj.References.Remove ThisRef
Next
Application.DisplayAlerts = False
For Each WS In Excel4MacroSheets
WS.Delete
Next
For Each DLG In DialogSheets
DLG.Delete
Next
End Sub


--
Regards,
Tom Ogilvy

Rob van Gelder wrote in message
...
Michael,

Sub testit()
Dim wkbSource As Workbook, wkbDest As Workbook, wks As Worksheet
Dim blnFirstWks As Boolean

Set wkbSource = Workbooks.Open("C:\data.xls")

blnFirstWks = True
For Each wks In wkbSource.Worksheets
If blnFirstWks Then
wks.Copy
Set wkbDest = ActiveWorkbook
blnFirstWks = False
Else
wks.Copy After:=wkbDest.Worksheets(wkbDest.Worksheets.Count )
End If
With wkbDest.Worksheets(wkbDest.Worksheets.Count).Cells
.Copy
.PasteSpecial Paste:=xlValues
.Cells(1, 1).Select
End With
Next
Application.CutCopyMode = False

wkbDest.SaveAs "C:\Backup.xls"

wkbSource.Close False
wkbDest.Close False
End Sub

Rob


"Michael168" wrote in message
...
Hi, A Happy New Year Greetings to everybody here.

I hope someone here can help me for this task.
I have a file say "Data.xls" which has 25 sheets under different names.
I like to copy all the 25 sheets of "Data.xls" to a new file say
"Backup.xls" which contain only the values excluding all the formulas
and macros.

Any kind help is appreciated.
Thank you.

Michael


---
Message posted from http://www.ExcelForum.com/





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy for Backup Purpose.

Thank you to the two gentlemen, Rob van Gelder and Tom Ogilvy, fo
helping.

Regards,
Michae

--
Message posted from http://www.ExcelForum.com

Reply
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
How do I create a backup copy of my software? april Excel Discussion (Misc queries) 0 July 15th 06 09:36 PM
backup copy of a workbook R..VENKATARAMAN Excel Discussion (Misc queries) 0 February 1st 06 12:47 PM
backup copy of a workbook R..VENKATARAMAN Excel Discussion (Misc queries) 0 February 1st 06 12:24 PM
Automatic backup copy craigq Charts and Charting in Excel 2 April 11th 05 04:57 PM
How do i save backup copy in a different folder mekraj Excel Discussion (Misc queries) 3 December 17th 04 08:33 PM


All times are GMT +1. The time now is 06:26 PM.

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

About Us

"It's about Microsoft Excel"