简体   繁体   English

保护Excel中的单元格,但应该能够复制它们

[英]Protect cells in excel but should be able to copy them

If I use this code to protect a worksheet, how can I make it so that the user still can copy the cells? 如果我使用此代码来保护工作表,我该如何制作它以便用户仍然可以复制单元格? And can you specify certain cells that should NOT be protected, or at least the user should be able to edit them? 并且可以指定某些不应该受到保护的单元格,或者至少用户应该可以对其进行编辑吗?

Worksheets("EKONOMI").Protect UserInterfaceOnly:=True

You can define if user is allowed to select cells in protected sheet by using 您可以使用以下命令定义是否允许用户在受保护的工作表中选择单元格

Worksheets("EKONOMI").EnableSelection = xlNoRestrictions 'worksheet has to be protected for this to take effect

To make user able to edit certain cells you have to unlock the cells before the protection. 为了使用户能够编辑某些单元格,您必须在保护之前解锁单元格。 For instance you can use the following to make Range C3 as unlocked cell 例如,您可以使用以下命令将范围C3设为未锁定的单元格

ActiveSheet.Range("C3").Select
Selection.Locked = False

Sheets("EKONOMI").Activate ActiveSheet.Unprotect Password:="123" 'ActiveSheet.Protection.AllowEditRanges(1).Delete ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range("A1:A10") ActiveSheet.Protect Password:="123" Sheets(“ EKONOMI”)。激活ActiveSheet.Unprotect密码:=“ 123”'ActiveSheet.Protection.AllowEditRanges(1)。删除ActiveSheet.Protection.AllowEditRanges.Add标题:=“ Range1”,范围:= Range(“ A1: A10“)ActiveSheet.Protect密码:=” 123“

Please find the above code to protect sheet by allowing user to edit patricular range of cells. 请通过允许用户编辑单元格的范围来找到上述代码以保护工作表。

 ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range("A1:A10") 

Mention the range name and range size for the user to edit. 提及范围名称和范围大小供用户编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel 2013,单元格将无法保护 - Excel 2013, Cells Will Not Protect 从多个excel文件复制单元格并将它们粘贴到主文件中 - Copy cells from multiple excel files and paste them into master file 复制单元格但不替换它们 - copy cells but not replace them 使用VBA在Excel中复制单元格 - Copy cells in excel with vba Excel VBA Protect工作表,但允许复制 - Excel VBA Protect worksheet but allow copy VBA复制选定的单元格与数据(Excel)。 将它们粘贴到表中的特定行(Word) - VBA Copy selected cells with data (Excel). Paste them in specific row in a table (Word) 将超链接文本和纯文本复制到剪贴板,然后在一行的多个单元格中使用 Javascript/JQuery 将它们粘贴到 Excel? - Copy hyperlink text and plain text to the clipboard, then paste them into Excel using Javascript/JQuery in multiple cells of a row? Excel If语句,以检查单元格是否包含某些字符并将其复制到其他单元格 - Excel If statement to check if cell contains certain characters and copy them to other cells Excel宏复制包含当前数组值的所有单元格并将其粘贴到新工作簿中 - Excel Macro to copy all cells containing current array value and paste them to a new workbook 如何使用 Excel VBA 从两个工作簿中复制特定单元格并将它们合并为一个? - How do I use Excel VBA to copy specific cells from two workbooks and combine them into one?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM