LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Export Sheet Values to new workbook

You might want to know that in this scenario wksSource wasn't really
necessary since we could do this:

Set wkbTarget = Sheets("overview").Copy

...then do whatever with wkbTarget.

My point for using wksSource is that in some cases the formula refs may
result in unexpected behavior when copied to a new wkb and so may
require copying to the source wkb, convert formula results to constant
values, then Move the sheet into wkbTarget. So then...

Sub CopyOverview()
Dim wksSource As Worksheet, wkbTarget As Workbook
Dim SaveAsFilename As String, sWksName As String

SaveAsFilename = ThisWorkbook.Path & "\Overview-" _
& FileNameDateString(IncludeNone) & ".xls"
sWksName = Sheets("overview").Name

Set wksSource = Sheets("overview").Copy After:=Sheets("overview")
With wksSource
.UsedRange.Value = .UsedRange.Value
End With

Set wkbTarget = wksSource.Move
With wkbTarget
.Sheets(1).Name = sWksName
.SaveAs SaveAsFilename: .Close
End With
End Sub

After which you're returned to the source wkb which should be closed
without saving changes. If you're done with it after running the
CopyOverview procedure then you can incorporate that into the process.

Add var:
Dim wkbSource As Workbook
Set wkbSource = ActiveWorkbook

At the end of the proc:
wkbSource.Close SaveChanges:=False

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
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
Export specific cell values to an external workbook Razorboy Excel Programming 1 October 28th 08 02:08 AM
How to export a linked cell sheet to get only values. CAPTGNVR[_2_] Excel Programming 3 April 30th 08 11:42 AM
Export Specific Sheet in Listbox to New Workbook Carlee Excel Programming 1 April 13th 07 07:56 PM
Export selected Sheet in a new workbook with old workbook name! gr8guy Excel Programming 5 September 11th 04 01:53 AM
Export just one sheet from a workbook Grek[_3_] Excel Programming 2 May 9th 04 01:52 PM


All times are GMT +1. The time now is 05:14 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"