Copy and Paste Data from Protected sheet to new workbook

MisterMayhem869

New Member
Joined
Mar 10, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am trying to copy just the data to a new workbook. The source sheet is protected, the new workbook does not need to be. I am using the following code:

Sub CopyWorksheetValues()
Application.CopyObjectsWithCells = False
ActiveSheet.Copy
Cells.Copy
Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

End Sub

It does create the new workbook however I get a runtime error I would like to get rid of. I have experimented with ActiveSheet.Unprotect but have not had any luck so far. Any help would be gretly appreciated.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Please try this:

VBA Code:
Sub CopyWSValues()


Dim wksNew As Worksheet
Dim wksSource As Worksheet

Set wksSource = ActiveSheet

Workbooks.Add
Set wksNew = ActiveSheet

With wksSource

  .Cells.Copy

End With

With wksNew

  .Activate
  .Range("A1").PasteSpecial Paste:=xlPasteValues

End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,216
Messages
6,123,669
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top