跳到主要內容

如何保護單元格格式,但僅允許在Excel中輸入數據?

在許多情況下,您可能需要保護一系列單元格的格式,僅允許在Excel中輸入數據。 本文提供了三種方法來實現它。

保護單元格格式,但僅通過保護工作表允許數據輸入
保護單元格格式,但僅允許使用VBA代碼輸入數據
保護單元格格式,但僅允許使用Kutools for Excel輸入數據


保護單元格格式,但僅通過保護工作表允許數據輸入

為了保護單元格格式但僅允許輸入數據,您需要首先解鎖這些單元格,然後再保護工作表。 請執行以下操作。

1.選擇需要保護其格式但僅允許輸入數據的單元格,然後按 按Ctrl + 1 同時打開 單元格格式 對話框。

2。 在裡面 單元格格式 對話框中,取消選中 鎖定 下框 保護的故事 選項卡,然後單擊 OK 按鈕。 看截圖:

3.現在去點擊 回顧 > 保護工作表.

4.請在密碼欄中指定並確認您的密碼 保護工作表確認密碼 對話框。 看截圖:

現在,工作表已受保護,並且單元格格式未更改。 但是指定的單元只允許輸入數據。


保護單元格格式,但僅允許使用VBA代碼輸入數據

您也可以運行以下VBA腳本來保護單元格格式,但僅允許在Excel中輸入數據。 請執行以下操作。

1。 按 其他 + F11 鍵同時打開 Microsoft Visual Basic for Applications 窗口。

2。 在裡面 Microsoft Visual Basic for Applications 窗口,雙擊 的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的工作表設計實用程序輕鬆解鎖選定的單元格並保護工作表。

申請前 Excel的Kutools首先下載並安裝.

1。 點擊 Kutools 加 > 工作表設計 激活 設計 標籤。

2.選擇需要保護其格式但僅允許輸入數據的單元格,單擊 解鎖單元設計 選項卡,然後單擊 OK 彈出按鈕 Excel的Kutools 對話框。 看截圖:

3。 點擊 保護工作表 按鈕下 設計 標籤。

4.然後在 保護工作表 確認密碼 對話框。 看截圖:

現在,工作表已受保護。 並且指定的單元格僅允許數據輸入。

  如果您想免費試用(30天)此實用程序, 請點擊下載,然後按照上述步驟進行操作。


相關文章:

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為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