右クリック、ダブルクリックの操作
勤務表作成してます。
A1に「ON・OFF」を表示します。
「ON」のときに、ダブルクリックで、上のセルを表示、右クリックで「1」を表示します。
「OFF」のときは、コンテキストメニュ-(通常の操作)が出来るようにしたいのですが、ON.OFFの切り替え操作のVBAがわかりません。
よろしくお願いします。
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
' ActiveCell = ActiveCell.Offset(-1, 0).Value
'
' If Target = Range("$A$1") Then
' Cancel = True
If Range("$A$1").Value = "イベントON" Then
Range("$A$1").Value = "イベントOFF"
Else
Range("$A$1").Value = "イベントON"
ActiveCell = ActiveCell.Offset(-1, 0).Value
Exit Sub
End If
Cancel = True
If Range("$A$1").Value = "イベントOFF" Then
Exit Sub
End If
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
'ActiveCell = "1"
' If Target = Range("$A$1") Then
' Cancel = True
' If Range("$A$1").Value = "イベントON" Then
' Range("$A$1").Value = "イベントOFF"
If Range("$A$1").Value = "イベントON" Then
ActiveCell = "1"
Else: Range("$A$1").Value = "イベントOFF"
Exit Sub
End If
Cancel = True
If Range("$A$1").Value = "イベントOFF" Then
Exit Sub
End If
End Sub
お礼
回答有難うございます