通勤認定エクセルツール対応12 M1 対応
This commit is contained in:
@@ -11,16 +11,18 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
|
||||
If HasHeaderEdit = True Then Exit Sub
|
||||
|
||||
Application.EnableEvents = False
|
||||
On Error GoTo Finally
|
||||
|
||||
' Multi-cell selection not processed
|
||||
If Target.Count > 1 Then Exit Sub
|
||||
If Target.Count > 1 Then GoTo Finally
|
||||
|
||||
' === Column C changes: Create L column dropdown ===
|
||||
If Target.Column = 3 And Target.Row >= 7 Then
|
||||
Dim cell As Range
|
||||
For Each cell In Target
|
||||
If Trim(cell.Value) = "" Then
|
||||
Me.Cells(cell.Row, 12).Validation.Delete
|
||||
Call ClearDataRow(Me, START_COL + 1, END_COL, cell.Row, ERROR_COL)
|
||||
Call ClearDataRow(Me, cell.Row)
|
||||
Else
|
||||
Call BuildTokubetuDropdown(Me, "L", cell.Row)
|
||||
Call BuildRenrakuDropdown(Me, "K", cell.Row)
|
||||
@@ -31,22 +33,97 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
' === Column D changes: Fill E column ===
|
||||
If Target.Column = 4 And Target.Row >= 7 Then
|
||||
Dim z1Cache As Object: Set z1Cache = GetCache(CACHE_Z1)
|
||||
|
||||
Dim z4Rosen As Object: Set z4Rosen = GetCache(CACHE_Z4ROSEN)
|
||||
Dim cellD As Range
|
||||
For Each cellD In Target
|
||||
Dim dVal As String: dVal = Trim(cellD.Value)
|
||||
If dVal = "" Then
|
||||
Me.Cells(cellD.Row, 5).ClearContents
|
||||
Me.Cells(cellD.Row, 6).ClearContents
|
||||
Me.Cells(cellD.Row, 7).ClearContents
|
||||
Me.Cells(cellD.Row, 6).Validation.Delete
|
||||
Me.Cells(cellD.Row, 7).Validation.Delete
|
||||
Else
|
||||
If Not z1Cache Is Nothing And z1Cache.Exists(dVal) Then
|
||||
Dim valsD As Variant: valsD = z1Cache(dVal)
|
||||
Me.Cells(cellD.Row, 5).Value = valsD(0)
|
||||
If z1Cache.Exists(dVal) Then
|
||||
Dim kikan As Variant: kikan = z1Cache(dVal)
|
||||
Dim kikanName As String: kikanName = kikan(0)
|
||||
Me.Cells(cellD.Row, 5).Value = kikanName
|
||||
|
||||
If z4Rosen.Exists(kikanName) Then
|
||||
Call BuildZ4StationFromDropdown(Me, "F", cellD.Row, kikanName)
|
||||
Dim fromStations As Object: Set fromStations = z4Rosen(kikanName)
|
||||
Dim fromCell As Range: Set fromCell = Me.Cells(cellD.Row, 6)
|
||||
Dim fromStation As String: fromStation = Trim(fromCell.Value)
|
||||
If Not fromStations.Exists(fromStation) Or fromStation = "" Then
|
||||
fromCell.ClearContents
|
||||
Me.Cells(cellD.Row, 7).ClearContents
|
||||
Me.Cells(cellD.Row, 7).Validation.Delete
|
||||
Else
|
||||
Call BuildZ4StationToDropdown(Me, "G", cellD.Row, kikanName, fromStation)
|
||||
Dim toStations As Object: Set toStations = fromStations(fromStation)
|
||||
Dim toCell As Range: Set toCell = Me.Cells(cellD.Row, 7)
|
||||
Dim toStation As String: toStation = Trim(toCell.Value)
|
||||
|
||||
If Not toStations.Exists(fromStation) Or toStation = "" Then
|
||||
toCell.ClearContents
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
Me.Cells(cellD.Row, 6).ClearContents
|
||||
Me.Cells(cellD.Row, 7).ClearContents
|
||||
Me.Cells(cellD.Row, 6).Validation.Delete
|
||||
Me.Cells(cellD.Row, 7).Validation.Delete
|
||||
End If
|
||||
|
||||
Else
|
||||
Me.Cells(cellD.Row, 5).ClearContents
|
||||
Me.Cells(cellD.Row, 6).ClearContents
|
||||
Me.Cells(cellD.Row, 7).ClearContents
|
||||
Me.Cells(cellD.Row, 6).Validation.Delete
|
||||
Me.Cells(cellD.Row, 7).Validation.Delete
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Column E changes (rosen name): Build F column (station from) dropdown ===
|
||||
' If Target.Column = 4 And Target.Row >= 7 Then
|
||||
' Dim cellE As Range
|
||||
' For Each cellE In Target
|
||||
' Dim rosenVal As String: rosenVal = Trim(cellE.Value)
|
||||
' If rosenVal = "" Then
|
||||
' Me.Cells(cellE.Row, 6).ClearContents
|
||||
' Me.Cells(cellE.Row, 8).ClearContents
|
||||
' Me.Cells(cellE.Row, 6).Validation.Delete
|
||||
' Me.Cells(cellE.Row, 8).Validation.Delete
|
||||
' Else
|
||||
' Call BuildZ4StationFromDropdown(Me, "F", cellE.Row, rosenVal)
|
||||
' End If
|
||||
' Next
|
||||
' End If
|
||||
|
||||
' === Column F changes (station from): Build H column (station to) dropdown ===
|
||||
If Target.Column = 6 And Target.Row >= 7 Then
|
||||
Dim cellF As Range
|
||||
For Each cellF In Target
|
||||
Dim stationFrom As String: stationFrom = Trim(cellF.Value)
|
||||
Dim rosenForH As String: rosenForH = Trim(Me.Cells(cellF.Row, 5).Value)
|
||||
If stationFrom = "" Then
|
||||
Me.Cells(cellF.Row, 7).ClearContents
|
||||
Me.Cells(cellF.Row, 7).Validation.Delete
|
||||
Else
|
||||
Call BuildZ4StationToDropdown(Me, "G", cellF.Row, rosenForH, stationFrom)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
Application.EnableEvents = True
|
||||
Exit Sub
|
||||
|
||||
Finally:
|
||||
HandleError "Worksheet_Change"
|
||||
Application.EnableEvents = True
|
||||
End Sub
|
||||
|
||||
' Prevent insert/delete row in header area
|
||||
|
||||
Reference in New Issue
Block a user