Ẩn công thức trong excel

Liên hệ QC

dasoi1982

Thành viên mới
Tham gia
1/7/08
Bài viết
4
Được thích
0
Em sưu tầm được đoạn mã ẩn công thức trong excel. nhưng cái này không cho copy dữ liệu. Các Cao thủ chỉh sửa hộ em để đoạn mã này cho phép copy nhé.

Cảm ơn các anh/chị.





Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Dim rFormulaCheck As Range



On Error Resume Next

Sh.Unprotect Password:="Secret"

With Selection

.Locked = False

.FormulaHidden = False


End With



If Target.Cells.Count = 1 Then

If Target.HasFormula Then

With Target

.Locked = True

.FormulaHidden = True



End With



Sh.Protect Password:="Secret", UserInterFaceOnly:=True

End If

ElseIf Target.Cells.Count > 1 Then

Set rFormulaCheck = Selection.SpecialCells(xlCellTypeFormulas)

If Not rFormulaCheck Is Nothing Then

With Selection.SpecialCells(xlCellTypeFormulas)

.Locked = True

.FormulaHidden = True

End With

Sh.Protect Password:="Secret", UserInterFaceOnly:=True

End If

End If

On Error GoTo 0

End Sub
 
Trong lúc chờ các cao nhân thì làm thử theo cách của thấp nhân tôi xem sao

Bỏ dòng dưới đi thì ok

Sh.Protect Password:="Secret", UserInterFaceOnly:=True
 
Lần chỉnh sửa cuối:
Upvote 0
Web KT
Back
Top Bottom