VBA Copy a Worksheet to a New Sheet without Formulas

十年热恋 提交于 2021-01-28 11:12:36

问题


I am trying to copy whatever selected sheet (notwithstanding the name of the sheet) within the same workbook. First, I have tried the code of copying and renaming a new sheet (with formulas) that I found elsewhere. It is working well:

Public Sub CopySheetAndRename()
    Dim newName As String
     On Error Resume Next
    newName = InputBox("Enter the name for the copied worksheet")
     If newName <> "" Then
        ActiveSheet.Copy After:=Worksheets(Sheets.Count)
        On Error Resume Next
        ActiveSheet.Name = newName
    End If
End Sub

However, I would just like to have the newly created sheet without formulas. I tried to add the lines like: ActiveSheet.PasteSpecial Paste:=xlPasteValues but it is not working at all. I have read also this post Copy Excel sheet to another excel book without formulas without any result. Thank you for your help!

Stanley

来源:https://stackoverflow.com/questions/59773278/vba-copy-a-worksheet-to-a-new-sheet-without-formulas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!