简体   繁体   中英

Copy sheet to new workbook as values

I want to copy the final input sheet of data workbook to a new workbook as only values

I've tried this but it pastes the data as values

Sub CopyToNew()
Sheets("Final Input").Copy
End Sub
Option Explicit

Public Sub TestMe()

    Dim newWb As Workbook
    Dim newWbPath As String: newWbPath = ThisWorkbook.Path & "\NewWB.xlsx"
    Set newWb = Workbooks.Add

    ThisWorkbook.Worksheets("FinalCountDown").Cells.Copy
    newWb.Worksheets(1).Cells.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False

    newWb.SaveAs newWbPath
    newWb.Close

End Sub
  • It copies the cells from ThisWorkbook("FinalCountDown") to the first worksheet of a new Workbook.
  • Then the new workbook is named "NewWB.xlsx" and is saved in the same file as ThisWorkbook through the variable newWbPath .
  • At the end the newWb is closed with newWb.Close .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM