You are on page 1of 1

Option Explicit

Private Sub Worksheet_BeforeDelete()

End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)


' If [A1].Value = "1 번" Then
' Cancel = True
' Else
' Cancel = False
' End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)


Dim a As CommandBar
If Not Intersect(Target, [A1]) Is Nothing Then
On Error Resume Next
If [A1].Value = "1 번" Then
Call Add_CommandBar
Else
Call Del_CommandBar
End If
End If
On Error GoTo 0
End Sub

Private Sub Worksheet_Deactivate()


Call Del_CommandBar
End Sub

Private Sub Worksheet_Activate()


Call Add_CommandBar
End Sub
Sub Add_CommandBar()
Dim a As CommandBar
On Error Resume Next
If [A1].Value = "1 번" Then
Set a = Application.CommandBars("Cell")
With a.Controls.Add(Type:=msoControlButton, Before:=1)
.Caption = "위치 입력" '명령 이름
.FaceId = 136 '아이콘
.OnAction = "Load_Userform1" '유저폼 부르기
.Tag = "Test"
End With
End If
End Sub

Sub Del_CommandBar()
On Error Resume Next
Application.CommandBars("Cell").Reset
End Sub

You might also like