Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Cancel = True '入力状態解除 If Not (Application.Intersect(Range("不可勤務"), Target) Is Nothing) Then With frm不可勤務 .Show vbModeless Worksheet_SelectionChange Target End With ElseIf Not (Application.Intersect(Range("出力"), Target) Is Nothing) Then With frm勤務入力 .Show vbModeless Worksheet_SelectionChange Target End With End If End Sub '-------------------------------------- ' ワークシート制御 '-------------------------------------- Private Sub Worksheet_SelectionChange(ByVal Target As Range) ' ' ワークシートセルの選択位置が変更された場合の処理 ' Dim MyCell As Range Dim flg As Boolean If IsAllIntersect(Range("不可勤務"), Target) Then Call 不可勤務入力処理(Target) ElseIf IsAllIntersect(Range("出力"), Target) Then Call 手動勤務入力処理(Target) Else On Error Resume Next Unload frm不可勤務 Unload frm勤務入力 On Error Goto 0 End If End Sub Private Function IsAllIntersect(RangA As Range, RangeB As Range) As Boolean ' '全てが重なっているか? ' Dim MyCell As Range Dim flg As Boolean flg = True For Each MyCell In RangeB 'はみ出していたら処理しない If Application.Intersect(RangA, MyCell) Is Nothing Then flg = False Exit For End If Next IsAllIntersect = flg End Function