Bạn thử:Xin hỏi các thầy có code nào ẩn toàn bộ công thức trên toàn bộ shet không ạ. vì nhiều shet quá
Sub abc()
Dim Sh As Worksheet
On Error Resume Next
For Each Sh In ActiveWorkbook.Sheets
With Sh
.Unprotect Password:="123"
.Cells.Locked = False
.Cells.FormulaHidden = False
.Cells.SpecialCells(xlCellTypeFormulas, 23).Locked = True
.Cells.SpecialCells(xlCellTypeFormulas, 23).FormulaHidden = True
.Protect AllowDeletingRows:=True
.Protect AllowSorting:=True
.Protect AllowFiltering:=True
.Protect Password:="123"
End With
Next Sh
End Sub
Bạn thử:
PHP:Sub abc() Dim Sh As Worksheet On Error Resume Next For Each Sh In ActiveWorkbook.Sheets With Sh .Unprotect Password:="123" .Cells.Locked = False .Cells.FormulaHidden = False .Cells.SpecialCells(xlCellTypeFormulas, 23).Locked = True .Cells.SpecialCells(xlCellTypeFormulas, 23).FormulaHidden = True .Protect AllowDeletingRows:=True .Protect AllowSorting:=True .Protect AllowFiltering:=True .Protect Password:="123" End With Next Sh End Sub
Vậy muốn dùng 1 Sheets, thì bỏ vòng lặp For Each.. . là xong, có gì là khó khăn đâu nhỉ?Cái này là protect tất cả các sheet mà.
Vậy muốn dùng 1 Sheets, thì bỏ vòng lặp For Each.. . là xong, có gì là khó khăn đâu nhỉ?
anh ơi ẩn thì có ẩn rồi nhưng nó lại làm mất code dãn dòng tự động của e rồi. anh có cách khác không ạBạn thử:
PHP:Sub abc() Dim Sh As Worksheet On Error Resume Next For Each Sh In ActiveWorkbook.Sheets With Sh .Unprotect Password:="123" .Cells.Locked = False .Cells.FormulaHidden = False .Cells.SpecialCells(xlCellTypeFormulas, 23).Locked = True .Cells.SpecialCells(xlCellTypeFormulas, 23).FormulaHidden = True .Protect AllowDeletingRows:=True .Protect AllowSorting:=True .Protect AllowFiltering:=True .Protect Password:="123" End With Next Sh End Sub
Vậy thử chép cái này vào ThisWorkBook :Mình nghỉ chủ thớt muốn chỉ k hiện công thức, chứ không phải khóa những ô có công thức đâu.
Private Sub Workbook_Activate()
Application.DisplayFormulaBar = False
End Sub
cho vào làm sao nữa bạn ơiVậy thử chép cái này vào ThisWorkBook :
PHP:Private Sub Workbook_Activate() Application.DisplayFormulaBar = False End Sub
Anh đi xa chủ đề rồi nhé. Phân biệt rõ ràng giữa "Ẩn công thức" và "Bỏ hoàn toàn công thức (.Value)".PHP:Sheet1.UsedRange.Value = Sheet1.UsedRange.Value 'ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value'
Xong chỉ việc active WB lên thôi, đoạn code sẽ ẩn cái thanh fomular này đi này:cho vào làm sao nữa bạn ơi