ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy to protected sheet (https://www.excelbanter.com/excel-programming/272097-re-copy-protected-sheet.html)

Bob Phillips[_5_]

copy to protected sheet
 
Unprotect it first, do the copy, then protect it again.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"bob" wrote in message
. ca...
i am trying to copy to a range of unprotected cells in a protected sheet.
the following will give an error after paste if destination sheet is
protected.
what copy statement would work
thanks

' copy from data to test
Range("A1:P350").Select
Selection.Copy
Sheets("test").Select
Range("W8").Select
ActiveSheet.Paste


' add autofilter back
Range("W12:AL12").Select
Application.CutCopyMode = False
Selection.AutoFilter

End Sub





Ron de Bruin

copy to protected sheet
 
Or protect you sheets with code like this
in the Workbook open event of the Thisworkbook module

Private Sub Workbook_Open()
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
sh.Protect userinterfaceonly:=True
Next sh
Application.ScreenUpdating = True
End Sub

Your code will work then


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Bob Phillips" wrote in message ...
Unprotect it first, do the copy, then protect it again.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"bob" wrote in message
. ca...
i am trying to copy to a range of unprotected cells in a protected sheet.
the following will give an error after paste if destination sheet is
protected.
what copy statement would work
thanks

' copy from data to test
Range("A1:P350").Select
Selection.Copy
Sheets("test").Select
Range("W8").Select
ActiveSheet.Paste


' add autofilter back
Range("W12:AL12").Select
Application.CutCopyMode = False
Selection.AutoFilter

End Sub








All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com