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
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