I have the following code that is part of a long vba code, where it copies and paste two worksheets into new workbook. One of the sheet, I want to copy and paste special value and the other, I just want to copy as is. This is part of my code:
For some reason getting an error message with the With the multiple statement. Is there a more efficient way of writing this code. Thanks for your help.
Code:
With Application
.ScreenUpdating = False
' Copy specific sheets
' *SET THE SHEET NAMES TO COPY BELOW*
' Array("Sheet Name", "Another sheet name", "And Another"))
' Sheet names go inside quotes, seperated by commas
Sheets(Array("PSR TEMPLATE CONTROL", "PSR CALCULATOR")).Copy
On Error GoTo 0
' Paste sheets as values
' Remove External Links, Hperlinks and hard-code formulas
' Make sure A1 is selected on all sheets
With ws("PSR TEMPLATE CONTROL")
ws.Cells.Copy
ws.[A1].PasteSpecial Paste:=xlValues
ws.Cells.Hyperlinks.Delete
Application.CutCopyMode = False
ws.Protect Password:="ops"
ws.Visible = xlSheetHidden
End With
With ws("PSR CALCULATOR")
ws.Cells.Copy
ws.Cells.Hyperlinks.Delete
Application.CutCopyMode = False
ws.Protect Password:="ops"
ws.Visible = xlSheetHidden
End With
Cells(1, 1).Select
.ScreenUpdating = True
End With
For some reason getting an error message with the With the multiple statement. Is there a more efficient way of writing this code. Thanks for your help.
Last edited by a moderator: