简体   繁体   中英

Excel VBA Protect worksheet but allow copy

I'm using Excel 2010 and protect using the following line in VBA:

Worksheets("GL Codes").Protect Password:="xxxxxxxxx", AllowFiltering:=True, AllowFormattingCells:=True

However, I now receive an error when I double-click to run the below:

Range("A" & Target.Row).Copy Destination:=Range("A2")

How do I protect but still allow a copy via VBA?

Sorted it!

Just removed the 'locked' protection checkbox for cell A2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM