通勤認定エクセルツール対応12 表示しない対応
This commit is contained in:
@@ -150,6 +150,9 @@ Private Sub DO_CSV_Import(ws As Excel.Worksheet)
|
||||
For j = 0 To expectedColumnCount - 1
|
||||
ws.Cells(writeRow, ws.Range(colLetters(j) & "1").Column).Value = CleanCSVField(CStr(csvData(i, j + 1)))
|
||||
Next j
|
||||
If cfg.Exists("DisplayCol") Then
|
||||
Call BuildDisplayDropdown(ws, writeRow)
|
||||
End If
|
||||
writeRow = writeRow + 1
|
||||
Next i
|
||||
|
||||
|
||||
@@ -221,14 +221,29 @@ InvalidColumn:
|
||||
End Function
|
||||
|
||||
'Clear single row data and format
|
||||
Function ClearDataRow(ByVal ws As Worksheet, ByVal startCol As Long, ByVal endCol As Long, ByVal rowRow As Long, Optional ByVal errorCol As Long = 2)
|
||||
If rowRow >= 7 Then
|
||||
Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowRow, startCol), ws.Cells(rowRow, endCol))
|
||||
clearRange.ClearContents
|
||||
clearRange.Interior.Color = vbWhite
|
||||
ws.Range(ws.Cells(rowRow, errorCol), ws.Cells(rowRow, errorCol)).ClearContents
|
||||
Sub ClearDataRow(ByVal ws As Worksheet, ByVal rowNum As Long)
|
||||
Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig()
|
||||
If Not sheetConfDict.Exists(ws.CodeName) Then
|
||||
Err.Raise ERR_CONFIG_NOT_FOUND, "ClearDataRow", "Sheet not configured: " & ws.CodeName
|
||||
End If
|
||||
End Function
|
||||
|
||||
Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName)
|
||||
|
||||
Dim startRow As Long: startRow = sheetConf("StartRow")
|
||||
Dim startCol As String: startCol = sheetConf("StartCol")
|
||||
Dim endCol As String: endCol = sheetConf("EndCol")
|
||||
Dim errorCol As String: errorCol = sheetConf("ErrorCol")
|
||||
|
||||
Dim clearRange As Range: Set clearRange = ws.Range(ws.Cells(rowNum, startCol), ws.Cells(rowNum, endCol))
|
||||
clearRange.ClearContents
|
||||
clearRange.Interior.Color = vbWhite
|
||||
clearRange.Validation.Delete
|
||||
|
||||
Dim errorRange As Range: Set errorRange = ws.Range(ws.Cells(rowNum, errorCol), ws.Cells(rowNum, errorCol))
|
||||
errorRange.ClearContents
|
||||
errorRange.Interior.Color = vbWhite
|
||||
errorRange.Validation.Delete
|
||||
End Sub
|
||||
|
||||
'Clear all data rows from startRow to lastDataRow
|
||||
Sub ClearDataRows(ByVal ws As Worksheet)
|
||||
|
||||
@@ -399,6 +399,7 @@ Private Sub RefreshSheetDict()
|
||||
sheetConf("StartCol") = "C"
|
||||
sheetConf("EndCol") = "H"
|
||||
sheetConf("ErrorCol") = "B"
|
||||
sheetConf("DisplayCol") = "H"
|
||||
sheetConf("StartRow") = 7
|
||||
sheetConf("HeaderRow") = 5
|
||||
sheetConf("CSV_Encoding") = "utf-8"
|
||||
@@ -589,15 +590,27 @@ Private Sub RefreshSheetDict()
|
||||
End Sub
|
||||
|
||||
Public Function GetSheetConfig() As Object
|
||||
If sheetConfDict Is Nothing Then Call RefreshSheetDict
|
||||
If sheetConfDict Is Nothing Then
|
||||
Call RefreshSheetDict
|
||||
Call RefreshEnumCache
|
||||
End If
|
||||
Set GetSheetConfig = sheetConfDict
|
||||
End Function
|
||||
|
||||
Public Sub RefreshEnumCache()
|
||||
Dim fixedEnumCaches As Variant
|
||||
fixedEnumCaches = Array("tokubetuList", "kenshuList", "renrakuList", "oufukuList", "koutaiList", "higaitouList", "errorList")
|
||||
|
||||
Dim cacheName As Variant
|
||||
For Each cacheName In fixedEnumCaches
|
||||
Call RefreshCache(CStr(cacheName))
|
||||
Next cacheName
|
||||
End Sub
|
||||
|
||||
Public Sub RefreshMasterCache()
|
||||
' Fixed cache names
|
||||
Dim fixedCaches As Variant
|
||||
fixedCaches = Array(CACHE_Z1, CACHE_Z2, CACHE_Z3, CACHE_T1, CACHE_T2, CACHE_T3, CACHE_O1, CACHE_O2, CACHE_O3, _
|
||||
"tokubetuList", "kenshuList", "renrakuList", "oufukuList", "koutaiList", "higaitouList", "errorList")
|
||||
fixedCaches = Array(CACHE_Z1, CACHE_Z2, CACHE_Z3, CACHE_T1, CACHE_T2, CACHE_T3, CACHE_O1, CACHE_O2, CACHE_O3)
|
||||
|
||||
' Refresh fixed caches
|
||||
Dim cacheName As Variant
|
||||
@@ -605,6 +618,8 @@ Public Sub RefreshMasterCache()
|
||||
Call RefreshCache(CStr(cacheName))
|
||||
Call WriteCachesSheet(CStr(cacheName))
|
||||
Next cacheName
|
||||
|
||||
Call RefreshEnumCache
|
||||
End Sub
|
||||
|
||||
Public Sub RefreshKukanCache(ByVal sheetName As String)
|
||||
|
||||
@@ -218,6 +218,32 @@ Public Sub BuildRenrakuDropdown(ws As Worksheet, ByVal columnLetter As String, B
|
||||
End With
|
||||
End Sub
|
||||
|
||||
' Create display dropdown
|
||||
Public Sub BuildDisplayDropdown(ws As Worksheet, ByVal rowNum As Long)
|
||||
' validate sheet
|
||||
Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig()
|
||||
If Not sheetConfDict.Exists(ws.CodeName) Then
|
||||
Err.Raise ERR_CONFIG_NOT_FOUND, "BuildDisplayDropdown", "Sheet not configured: " & ws.CodeName
|
||||
End If
|
||||
|
||||
' validate Display
|
||||
Dim sheetConf As Object: Set sheetConf = sheetConfDict(ws.CodeName)
|
||||
If Not sheetConf.Exists("DisplayCol") Then
|
||||
Err.Raise ERR_CONFIG_NOT_FOUND, "BuildDisplayDropdown", "Display Column not configured: " & ws.CodeName
|
||||
End If
|
||||
|
||||
Dim displayCol As String: displayCol = sheetConf("DisplayCol")
|
||||
Dim dropdownList As String: dropdownList = "0:OFF,1:ON"
|
||||
With ws.Range(displayCol & rowNum).Validation
|
||||
.Delete
|
||||
.Add Type:=xlValidateList, Formula1:=dropdownList
|
||||
.IgnoreBlank = True
|
||||
.InCellDropdown = True
|
||||
.InputTitle = ""
|
||||
.InputMessage = ""
|
||||
End With
|
||||
End Sub
|
||||
|
||||
' Build dropdown using Caches sheet
|
||||
Public Sub BuildDropdownFromCacheNamedRange(ws As Worksheet, columnLetter As String, rowNum As Long, cacheName As String)
|
||||
Dim formula As String: formula = GetValidationFormula(cacheName)
|
||||
|
||||
@@ -13,6 +13,39 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Dim HasHeaderEdit As Boolean: HasHeaderEdit = CheckHeaderEdit(Me, Target)
|
||||
If HasHeaderEdit = True Then Exit Sub
|
||||
|
||||
' Check if cache is loaded
|
||||
Application.EnableEvents = False
|
||||
On Error 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
|
||||
Call ClearDataRow(Me, cell.Row)
|
||||
Else
|
||||
Call BuildDisplayDropdown(Me, cell.Row)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Column D changes: Fill E column ===
|
||||
If Target.Column = 8 And Target.Row >= 7 Then
|
||||
Dim cellH As Range
|
||||
For Each cellH In Target
|
||||
Dim displayValue As String: displayValue = Trim(cellH.Value)
|
||||
If displayValue <> "" Then
|
||||
cellH.Value = GetCode(displayValue)
|
||||
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
|
||||
@@ -46,10 +79,10 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
|
||||
checkResult = CheckRequired(ws, rowNum, 3, errorCol)
|
||||
If checkResult = False Then Exit Sub
|
||||
|
||||
checkResult = CheckChar(ws, rowNum, 3, 2, errorCol)
|
||||
checkResult = CheckChar(ws, rowNum, 3, 6, errorCol)
|
||||
If checkResult = False Then Exit Sub
|
||||
|
||||
checkResult = CheckAlphanumeric(ws, rowNum, 3, 2, errorCol)
|
||||
checkResult = CheckAlphanumeric(ws, rowNum, 3, 6, errorCol)
|
||||
If checkResult = False Then Exit Sub
|
||||
|
||||
checkResult = CheckDuplicate(ws, rowNum, 3, errorCol)
|
||||
|
||||
Reference in New Issue
Block a user