diff --git a/src/sh/tuk/module/Common_Functions.bas b/src/sh/tuk/module/Common_Functions.bas index 2f7616e..9a94659 100644 --- a/src/sh/tuk/module/Common_Functions.bas +++ b/src/sh/tuk/module/Common_Functions.bas @@ -368,12 +368,12 @@ Function CheckHeaderEdit(ByVal ws As Worksheet, ByVal Target As Range) As Boolea Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName) Dim filterRow As Long: filterRow = sheetConf("FilterRow") - ' Check header row (headerRow) cannot be edited + ' Check rows 1 to filterRow cannot be edited Dim r As Long For r = Target.Row To Target.Row + Target.Rows.Count - 1 - If r = 1 Or r = filterRow Then + If r >= 1 And r <= filterRow Then Application.EnableEvents = False - MsgBox "Header or type definition row cannot be edited.", vbExclamation + MsgBox "Cannot edit rows 1 to " & filterRow & ".", vbExclamation Application.Undo Application.EnableEvents = True diff --git a/src/sh/tuk/sheet/C1.cls b/src/sh/tuk/sheet/C1.cls index 9e01982..593f94b 100644 --- a/src/sh/tuk/sheet/C1.cls +++ b/src/sh/tuk/sheet/C1.cls @@ -232,6 +232,18 @@ Finally: Application.EnableEvents = True ' End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + Private Sub RebuildDropdownsForTarget(ByVal Target As Range) If Target Is Nothing Then Exit Sub diff --git a/src/sh/tuk/sheet/M1.cls b/src/sh/tuk/sheet/M1.cls index 8a8dcd9..7214296 100644 --- a/src/sh/tuk/sheet/M1.cls +++ b/src/sh/tuk/sheet/M1.cls @@ -10,7 +10,10 @@ Private Sub Worksheet_Change(ByVal Target As Range) Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target) If HasHeaderEdit = True Then Exit Sub - + + ' Multi-cell selection not processed + If Target.Count > 1 Then Exit Sub + ' === Column C changes: Create L column dropdown === If Target.Column = 3 And Target.Row >= 7 Then Dim cell As Range @@ -46,6 +49,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End If End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + Private Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/M2.cls b/src/sh/tuk/sheet/M2.cls index 34fd686..1a0e85c 100644 --- a/src/sh/tuk/sheet/M2.cls +++ b/src/sh/tuk/sheet/M2.cls @@ -94,6 +94,18 @@ Finally: Application.EnableEvents = True ' End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/O1.cls b/src/sh/tuk/sheet/O1.cls index 0276b40..c233aa9 100644 --- a/src/sh/tuk/sheet/O1.cls +++ b/src/sh/tuk/sheet/O1.cls @@ -13,6 +13,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) If HasHeaderEdit = True Then Exit Sub End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/O2.cls b/src/sh/tuk/sheet/O2.cls index 8cfc547..106d756 100644 --- a/src/sh/tuk/sheet/O2.cls +++ b/src/sh/tuk/sheet/O2.cls @@ -14,6 +14,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/T1.cls b/src/sh/tuk/sheet/T1.cls index 64891cd..2a96df4 100644 --- a/src/sh/tuk/sheet/T1.cls +++ b/src/sh/tuk/sheet/T1.cls @@ -15,6 +15,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + ' Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/T2.cls b/src/sh/tuk/sheet/T2.cls index af22fb2..c429e0b 100644 --- a/src/sh/tuk/sheet/T2.cls +++ b/src/sh/tuk/sheet/T2.cls @@ -15,6 +15,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + ' Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/T3.cls b/src/sh/tuk/sheet/T3.cls index 153a46a..acc07dd 100644 --- a/src/sh/tuk/sheet/T3.cls +++ b/src/sh/tuk/sheet/T3.cls @@ -15,6 +15,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + ' Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/Z1.cls b/src/sh/tuk/sheet/Z1.cls index 3dd78ff..4ac35c2 100644 --- a/src/sh/tuk/sheet/Z1.cls +++ b/src/sh/tuk/sheet/Z1.cls @@ -15,6 +15,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + ' Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/Z2.cls b/src/sh/tuk/sheet/Z2.cls index 241c410..e7a6b77 100644 --- a/src/sh/tuk/sheet/Z2.cls +++ b/src/sh/tuk/sheet/Z2.cls @@ -15,6 +15,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + ' Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/Z3.cls b/src/sh/tuk/sheet/Z3.cls index 39f2f45..032d5ce 100644 --- a/src/sh/tuk/sheet/Z3.cls +++ b/src/sh/tuk/sheet/Z3.cls @@ -15,6 +15,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + ' Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/src/sh/tuk/sheet/Z4.cls b/src/sh/tuk/sheet/Z4.cls index 00b3d77..71e89f0 100644 --- a/src/sh/tuk/sheet/Z4.cls +++ b/src/sh/tuk/sheet/Z4.cls @@ -15,6 +15,18 @@ Private Sub Worksheet_Change(ByVal Target As Range) End Sub +' Prevent insert/delete row in header area +Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) + Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig() + Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName) + Dim filterRow As Long: filterRow = sheetConf("FilterRow") + + If Target.Row < filterRow + 1 Then + Cancel = True + MsgBox "Cannot insert or delete row in header area.", vbExclamation + End If +End Sub + ' Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As Long) On Error GoTo ErrHandler diff --git a/通勤手当テンプレート20260515.xlsm b/通勤手当テンプレート20260515.xlsm index 26f5489..5282ef6 100644 Binary files a/通勤手当テンプレート20260515.xlsm and b/通勤手当テンプレート20260515.xlsm differ