跳到主要内容

如何保护单元格格式,但仅允许在Excel中输入数据?

在许多情况下,您可能需要保护一系列单元格的格式,仅允许在Excel中输入数据。 本文提供了三种方法来实现它。

保护单元格格式,但仅通过保护工作表允许数据输入
保护单元格格式,但仅允许使用VBA代码输入数据
保护单元格格式,但只允许使用 Kutools for Excel 输入数据


保护单元格格式,但仅通过保护工作表允许数据输入

为了保护单元格格式但仅允许输入数据,您需要首先解锁这些单元格,然后再保护工作表。 请执行以下操作。

1.选择需要保护其格式但仅允许输入数据的单元格,然后按 按Ctrl + 1 同时打开 单元格格式 对话框。

2.在 单元格格式 对话框中,取消选中 锁定 下框 的故事 选项卡,然后单击 OK 按钮。 看截图:

3.现在去点击 进入步骤三:发送 > 保护工作表.

4.请在密码栏中指定并确认您的密码 保护工作表确认密码 对话框。 看截图:

现在,工作表已受保护,并且单元格格式未更改。 但是指定的单元仅允许数据输入。


保护单元格格式,但仅允许使用VBA代码输入数据

您也可以运行以下VBA脚本来保护单元格格式,但仅允许在Excel中输入数据。 请执行以下操作。

1。 按 其他 + F11 按键同时打开 Microsoft Visual Basic应用程序 窗口。

2.在 Microsoft Visual Basic应用程序 窗口,双击 的ThisWorkbook 在“项目”窗格上,然后将以下VBA代码复制并粘贴到 本工作簿(代码) 窗口。

VBA代码:保护单元格格式,但仅允许输入数据

Sub AllowDataEntryOnly()
    ActiveSheet.Protect Userinterfaceonly:=True, AllowFiltering:=True
    Range("C2:C20").Locked = False
        MsgBox "Only allow data entry in range C2:C20", vbInformation, "Kutools for Excel"
End Sub

备注:在代码中,C2:C20是您只允许输入数据的单元格的范围。 请根据需要更改范围。

3。 按 F5 键来运行代码。在弹出的 Kutools for Excel 对话框中,单击“确定”按钮。

现在,工作表以及单元格格式都受到保护。 并且仅允许指定的单元格进行数据输入。


保护单元格格式,但只允许使用 Kutools for Excel 输入数据

您可以使用 Kutools for Excel 的工作表设计实用程序轻松解锁选定的单元格并保护工作表。

申请前 Kutools for Excel首先下载并安装.

1。 点击 Kutools 加 > 工作表设计 激活 设计 标签。

2.选择需要保护其格式但仅允许输入数据的单元格,单击 解锁单元 在下面 设计 选项卡,然后单击 OK 弹出按钮 Kutools for Excel 对话框。 看截图:

3。 点击 保护工作表 按钮下 设计 标签。

4.然后在 保护工作表 确认密码 对话框。 看截图:

现在,工作表已受保护。 并且指定的单元格仅允许数据输入。

  如果您想免费试用(30天)此实用程序, 请点击下载,然后按照上述步骤进行操作。


相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Cette manœuvre ne fonctionne pas. Les formules ne sont toujours pas sécurisées
This comment was minimized by the moderator on the site
Tried that and save, after I close file, it asks for password. Which of course there is none and I am now locked out of my workbook. Pls adv
This comment was minimized by the moderator on the site
Hi Pamela,
If you apply the VBA code mentioned in the post. The worksheet is protected, but there is no password. Please click Review > Unprotect Worksheet to unprotect the worksheet without entering a password.
This comment was minimized by the moderator on the site
I read the "Protect cell formatting but only allow data entry by protecting worksheet" is wrong. The format can still be changed. I thought you had found something there. You did not...
This comment was minimized by the moderator on the site
Yeah.. this does not work at all. It does not prevent the cells from being formatted. Bad site!
This comment was minimized by the moderator on the site
Hi, Thank you for the code, it was very useful. I was wondering if you could put in a part where the supervisor could enter a code so that they could edit the formatting and then locking it again without having to delete the code every time this is needed.
This comment was minimized by the moderator on the site
I followed the directions, but was not able to enter data into the locked cells as mentioned in the instructions. Anyone have a solution?
This comment was minimized by the moderator on the site
Hi kristen,
For a protected worksheet, you can only enter data into the unlocked cells.
This comment was minimized by the moderator on the site
It still allows for users to delete the formulas...
This comment was minimized by the moderator on the site
It is any way that you can lock the cells for the formulas and allow input data only? With regular excel not having enterprise
This comment was minimized by the moderator on the site
The "Protecting Worksheet" instructions do not lock the formatting. If you copy cells in normally the formatting is copied over with them.
This comment was minimized by the moderator on the site
Please let us know if found a solution for this specific case.
This comment was minimized by the moderator on the site
The solution is here, however it is very medicore because You may forget about ctrl + z :P Useless if You want to preapare worksheet for others but usefull for own purposes if set as "ctrl + shift + v"

https://www.extendoffice.com/documents/excel/2545-excel-set-paste-values-as-default.html
This comment was minimized by the moderator on the site
agreed.... did you find any other solution to this anywhere?
This comment was minimized by the moderator on the site
Came here looking for a solution to this same problem which Matt mentioned.
If you paste a cell from another sheet to the protected cell, unfortunately cell formatting is overwritten!
Any solution to this issue so far?
This comment was minimized by the moderator on the site
I am having the same. The whole reason I want to protect the formatting is to stop the copy & paste issue! I hope someone has a solution.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations