Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim sttRow As Long
Dim ENDROW As Long
Dim ttlRow As Long
Dim MaxRow As Long '最終行
Dim MaxCol As Long '最終列
With ThisWorkbook.Worksheets("Main")
'テーブル範囲の最終行取得
With .ListObjects(1)
ttlRow = .HeaderRowRange.Row
If .DataBodyRange Is Nothing Then
MaxRow = ttlRow + 1
Else
MaxRow = ttlRow + .DataBodyRange.Rows.Count
End If
End With
End With
With Target
'E-F列
If (.Column = 7 Or .Column = 8) And _
(.Row >= 13 And .Row <= MaxRow) Then
Cancel = True
With Cells(ActiveCell.Row, 7)
If .Value <> ChrW("&H2713") Then
.Value = ChrW("&H2713")
.Resize(, 2).Interior.Color = RGB(255, 217, 102) 'ソフトイエロー
Else
.Value = ActiveCell.Row - 12
.Resize(, 2).Interior.Color = vbWhite '背景色白
End If
End With
.Calculate
End If
End With
End Sub
コメント