Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default how to copy worksheet to new workbook with values only

Hello,
I'm trying to save one sheet in one workbook as a new workbook. My
code is shown below. There is one range on the worksheet which has
formulas in it. That range is named "customer_name". I don't want to
copy the formulas. I want only values to go to the new workbook.

The code I have below works, but it is slow. I was wondering if there
was a way to modify the Worksheets("PO").copy command so that it only
copies only values.

thanks in advance for your help.
Andy

Dim wb As Workbook
Worksheets("PO").Copy
Set wb = ActiveWorkbook
wb.SaveAs "NEW_NAME.XLSX"

wb.Worksheets("PO").Range("customer_name").Select
selection.Copy
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

wb.Close
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default how to copy worksheet to new workbook with values only

Try...

Sub CopySheetToNewWkb()
Sheets("PO").Copy 'becomes active wkb/wks
With ActiveSheet.UsedRange
.Value = .Value
End With 'ActiveSheet.UsedRange
With ActiveWorkbook
.SaveAs "FullPathAndFilename"
.Close
End With
End Sub

--
Garry

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default how to copy worksheet to new workbook with values only

On Jul 7, 12:20*pm, GS wrote:
Try...

Sub CopySheetToNewWkb()
* Sheets("PO").Copy 'becomes active wkb/wks
* With ActiveSheet.UsedRange
* * .Value = .Value
* End With 'ActiveSheet.UsedRange
* With ActiveWorkbook
* * .SaveAs "FullPathAndFilename"
* * .Close
* End With
End Sub

--
Garry

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


Thanks. That's quite a bit faster than my code.

Andy
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default how to copy worksheet to new workbook with values only

Andrew submitted this idea :
On Jul 7, 12:20*pm, GS wrote:
Try...

Sub CopySheetToNewWkb()
* Sheets("PO").Copy 'becomes active wkb/wks
* With ActiveSheet.UsedRange
* * .Value = .Value
* End With 'ActiveSheet.UsedRange
* With ActiveWorkbook
* * .SaveAs "FullPathAndFilename"
* * .Close
* End With
End Sub

--
Garry

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


Thanks. That's quite a bit faster than my code.

Andy


You're very welcome! Always glad to be of help...

--
Garry

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


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
Copy values of worksheet a to workbook b Nev Excel Discussion (Misc queries) 5 April 8th 09 09:35 PM
Copy Values From Worksheet to another Worksheet same Workbook Joe K. Excel Programming 1 October 6th 07 08:45 PM
Copy Values from WorkSheet back to Another Workbook Replacing Values in Worksheet bobwilson[_16_] Excel Programming 0 April 3rd 06 09:50 PM
automatically copy values of worksheet into new workbook Jane Excel Programming 4 July 7th 05 03:10 PM
Copy worksheet values and formats into another workbook Rick_Wendt Excel Programming 1 October 20th 04 08:14 PM


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