问题
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