• 2

Excel 格式化條件被洗掉的問題~

各位好
請問Excel中使用格式化條件如何避免被修改掉?
上網找了都是使用保護工作表,照著用還是會被修改
從B2複製到A2 A2的格式化條件就消失了
請問有甚麼辦法可以避免掉 格式化條件被修改掉?
A欄 B欄都需要輸入~ 但是B欄沒有格式化條件

Excel 格式化條件被洗掉的問題~
2017-12-18 12:02 發佈
 小眠 wrote:
各位好請問Excel...(恕刪)


貼上時,選擇貼上值,詳下圖:
我知道可以用貼上值得方式,但是目前是要給其他人用
~.~所以才要想辦法看能不能用擋住的
1.你的儲存格格式中的"鎖定"要打勾
2.選取保護工作表的時候"選取鎖定的儲存格"要取消打勾

這樣才是有保護到儲存格

已樓主目前的設定 該儲存格已經被取消鎖定
然後保護工作表的內容中
您設定 允許修改"未"鎖定的儲存格
所以才會設定不成功
類似發問與解法回覆,可參考:https://goo.gl/Mre2BR

若無法教會同事使用貼上值的方式,
可錄製建立格式化規則的巨集後,
程式碼放至Worksheet_Change,
設定只要A欄一變更,就建立格式化規則

VBA巨集效果如下圖:

joblyc017 wrote:
類似發問與解法回覆,...(恕刪)


這個方法可行! 感謝~
我在試用看看 謝謝
不過我一次有設好幾個格式化條件 到時候再看看會不會有問題
另外可以問一下 那個GIF動畫要怎麼用XD

rock30509 wrote:
1.你的儲存格格式中...(恕刪)


我測試之後 儲存格格式-->鎖定-->打勾
保護工作表-->鎖定儲存格 不勾選..
這樣我會沒有辦法去編輯到 有格式化條件的儲存格阿0.0
還是我有設定錯誤?
https://www.extendoffice.com/documents/excel/3842-excel-restrict-paste-values-only.html

加個巨集,限制成只能 paste by value
太失敗,我試了我上面找到的,爛透了

所以,我重新找了一下

GOOGLE excel vba disable paste with paste by value

找到這個
https://www.mrexcel.com/forum/excel-questions/575750-restrict-paste-paste-values-using-vba.html

但是不能用

因為中文 英文上的差異

參考這個,找出 中文英文上的差異
http://discuz.bestdaylong.com/thread-30708-1-1.html


修正之後的結果就是

這個程式就是檢查復原這個功能,是不是有貼上,如果有貼上,那就複制數值,還原,然後選擇性貼上數值



Private Sub Worksheet_Change(ByVal Target As Range)


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This code will undo PASTE and instead show a message asking for Pasting as Values.
' This allow you to retain FORMATS in all of the cells in all of the sheets, but will
' also allow the user to COPY and PASTE data
' Since this subroutine is located in an Object Module, it should only affect this worksheet.
' Just in case, Disable and EnableEvents lines have been added in Module_ConsistencyChecks, Module_Output
' and Module_Reset to avoid EventLoops
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim UndoString As String
Dim Msg, Style, Title, Response, MyString ' For the MsgBox
On Error Resume Next ' Next line is prone to error
UndoString = Application.CommandBars("Standard").Controls("復原(&U)").List(1)

If Left(UndoString, 2) = "貼上" And UndoString <> "選擇性貼上" Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Undo
Msg = _
"You are pasting information. Doing that will modify the Data Validation and corrupt the file." & _
"The operation was undone. If you want to paste data, please select paste as values. Thanks!" ' Define message.
Style = vbOKOnly ' Define buttons.
Title = "Invalid Action" ' Define title.
Response = MsgBox(Msg, Style, Title)
Worksheets("Loan_Information").Protect
End If

Application.ScreenUpdating = True
Application.EnableEvents = True
On Error GoTo 0
End Sub



Eigen wrote:
太失敗,我試了我上面...(恕刪)


感謝,這方法剛剛我去測試是可以擋掉 貼上
不過我的Excel 2010 要用Application.CommandBars("Standard").Controls(14).List(1)
不可以用Controls("復原(&U)") 會抓不到資料,我把系統抓出來的復原(&U)貼到VBA裡面會變成 復原??(&U) 看來有些字抓不到所以判斷會失敗吧

不過畢竟使用者用的方法好多 刪除,插入,複製貼上...等
看來我還是每次都格式化條件一次 = =
  • 2
內文搜尋
X
評分
評分
複製連結
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?