|
* 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.
- 엑셀 버전(95,97,2000,xp,2003,2007):2007
* 아래줄에 질문을 작성하세요 >>
안녕하세요.
VBA를 이용하여 "A2:C11"까지 수정을 못하게 하고 싶습니다.
어떤 함수를 써야 하나요?
쉬운듯 하면서도 막상 Protect 등으로 보호하려니까 안되네요..
아울러 특정 시트에서 모든 Shape를 삭제하되 커멘드버튼만 삭제안되게 할 수 있나요?
감사합니다.
==============[cycy님 글에 대한 답변입니다]==============
VBA를 이용하여 "A2:C11"까지 수정을 못하게 하고 싶습니다.
==>
Sub userProtect()
With ActiveSheet
.Unprotect
With .Cells
.Locked = False
.FormulaHidden = False
End With
With .Range("A2:C11")
.Locked = True
.FormulaHidden = False
End With
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
End Sub
아울러 특정 시트에서 모든 Shape를 삭제하되 커멘드버튼만 삭제안되게 할 수 있나요?
==>
Sub del_Shape()
Dim shpX As Shape
Dim blnX As Boolean
For Each shpX In ActiveSheet.Shapes
blnX = True
Select Case shpX.Type
Case msoOLEControlObject
If shpX.DrawingObject.OLEType = 2 Then
If InStr(shpX.OLEFormat.progID, "CommandButton") Then blnX = False
End If
Case Else
If shpX.FormControlType = 0 Then blnX = False
End Select
If blnX Then shpX.Delete
Next
End Sub |
|