code ẩn công thức (5 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

maiban116

Thành viên thường trực
Tham gia
29/3/15
Bài viết
361
Được thích
20
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á
 
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á
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
 
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

Cái này là protect tất cả các sheet mà.
 
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
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 ạ
 
PHP:
Sheet1.UsedRange.Value = Sheet1.UsedRange.Value
'ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value'
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)".
Kẻo chủ thớt dùng code xong lại khóc lóc vì mất hết công thức của file. Theo em có 2 cách thì anh @phulien1902 đã nêu cả 2 rồi.
Bài đã được tự động gộp:

cho vào làm sao nữa bạn ơi
Xong chỉ việc active WB lên thôi, đoạn code sẽ ẩn cái thanh fomular này đi này:
1539631353336.png
 
Web KT

Bài viết mới nhất

Back
Top Bottom