通勤認定エクセルツール対応11
This commit is contained in:
@@ -161,8 +161,9 @@ Private Function GenerateSqlForRow(ws As Worksheet, rowNum As Long, codePrefix A
|
||||
nums = Mid(dataType, pos + 1)
|
||||
nums = Trim(Left(nums, InStr(nums, ")") - 1))
|
||||
precision = nums
|
||||
If InStr(UCase(dataType), "NUMBER") > 0 And InStr(nums, ", ") > 0 Then
|
||||
vScale = Trim(Mid(nums, InStr(nums, ", ") + 1))
|
||||
If InStr(UCase(dataType), "NUMBER") > 0 And InStr(nums, ",") > 0 Then
|
||||
precision = Trim(Mid(nums, 1, InStr(nums, ",") - 1))
|
||||
vScale = Trim(Mid(nums, InStr(nums, ",") + 1))
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -197,8 +198,8 @@ Private Function GenerateSqlForRow(ws As Worksheet, rowNum As Long, codePrefix A
|
||||
Dim nullable As String: nullable = IIf(isRequired = "TRUE", "FALSE", "TRUE")
|
||||
|
||||
GenerateSqlForRow = "INSERT INTO SH_CSV_ITEM_DEFINITION VALUES (" & _
|
||||
code & ", " & itemSeq & ", " & itemTitleStr & ", '' ," & isPk & ", " & dataTypeStr & ", " & _
|
||||
precision & ", " & vScale & ", " & nullable & ", " & isFormatCheck & ", '' ," & isExistCheck & ", " & _
|
||||
code & ", " & itemSeq & ", " & itemTitleStr & ", '', " & isPk & ", " & dataTypeStr & ", " & _
|
||||
precision & ", " & vScale & ", " & nullable & ", " & isFormatCheck & ", '', " & isExistCheck & ", " & _
|
||||
allowedValuesStr & ", " & masterSybt & ", " & isRelationCheck & ", " & isJsonIgnore & ", " & cmnuser & ", " & dmndate & ");"
|
||||
End Function
|
||||
|
||||
|
||||
@@ -152,11 +152,12 @@ Private Function LookupM2Cache() As Object
|
||||
Dim r As Long
|
||||
For r = startRow To lastRow
|
||||
Dim kukanCode As String: kukanCode = Trim(ws.Cells(r, 3).Value) ' C column
|
||||
Dim kanshu As String: kanshu = Trim(ws.Cells(r, 9).Value) ' I column
|
||||
Dim kenshu As String: kenshu = Trim(ws.Cells(r, 9).Value) ' I column
|
||||
Dim code As String: code = Trim(ws.Cells(r, 10).Value) ' J column
|
||||
Dim name As String: name = Trim(ws.Cells(r, 11).Value) ' K column
|
||||
Dim teikikikanNum As String: teikikikanNum = Trim(ws.Cells(r, 14).Value) ' N column
|
||||
|
||||
If kukanCode = "" Or kanshu = "" Or code = "" Then GoTo NextRow
|
||||
If kukanCode = "" Or kenshu = "" Or code = "" Then GoTo NextRow
|
||||
|
||||
' Outer level: kukanCode
|
||||
If Not resultCache.Exists(kukanCode) Then
|
||||
@@ -164,17 +165,28 @@ Private Function LookupM2Cache() As Object
|
||||
resultCache.Add kukanCode, innerDict
|
||||
End If
|
||||
|
||||
' Middle level: kanshu
|
||||
' Middle level: kenshu
|
||||
Set innerDict = resultCache(kukanCode)
|
||||
If Not innerDict.Exists(kanshu) Then
|
||||
If Not innerDict.Exists(kenshu) Then
|
||||
Dim innermostDict As Object: Set innermostDict = CreateObject("Scripting.Dictionary")
|
||||
innerDict.Add kanshu, innermostDict
|
||||
innerDict.Add kenshu, innermostDict
|
||||
End If
|
||||
|
||||
' Inner level: code -> name
|
||||
Set innermostDict = innerDict(kanshu)
|
||||
' Inner level: code -> {name, teikikikanNumList}
|
||||
Set innermostDict = innerDict(kenshu)
|
||||
Dim infoDict As Object
|
||||
If Not innermostDict.Exists(code) Then
|
||||
innermostDict.Add code, name
|
||||
Set infoDict = CreateObject("Scripting.Dictionary")
|
||||
infoDict.Add "name", name
|
||||
infoDict.Add "teikikikanNum", Array(teikikikanNum)
|
||||
innermostDict.Add code, infoDict
|
||||
Else
|
||||
' Already exists, add teikikikanNum to the list
|
||||
Set infoDict = innermostDict(code)
|
||||
Dim oldList As Variant: oldList = infoDict("teikikikanNum")
|
||||
ReDim Preserve oldList(UBound(oldList) + 1)
|
||||
oldList(UBound(oldList)) = teikikikanNum
|
||||
infoDict("teikikikanNum") = oldList
|
||||
End If
|
||||
|
||||
NextRow:
|
||||
@@ -274,7 +286,7 @@ Private Sub RefreshSheetDict()
|
||||
sheetConf("CSV_Encoding") = "shift_jis"
|
||||
sheetConf("HasHeader") = True
|
||||
sheetConf("ExpectedColumnCount") = 41
|
||||
sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "W", "X", "Y", "Z", "AD", "AE", "AF", "AG", "AK", "AL", "AM", "AN", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC")
|
||||
sheetConf("HeaderColumns") = Array("C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "W", "X", "Y", "Z", "AA", "AE", "AF", "AG", "AH", "AI", "AM", "AN", "AO", "AP", "AQ", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE", "BF", "BG")
|
||||
sheetConf("AlwaysQuote") = False
|
||||
sheetConf("FilterRow") = 7
|
||||
Set sheetConfDict("C1") = sheetConf
|
||||
|
||||
@@ -10,7 +10,6 @@ Option Explicit
|
||||
' - BuildKoutaiList
|
||||
' - BuildKetteiList
|
||||
' - BuildHigaitouList
|
||||
' - BuildMonthAmountKbnList
|
||||
' - BuildKanshokuList
|
||||
' - BuildKenshuList
|
||||
' ============================================================
|
||||
@@ -127,24 +126,6 @@ Public Function BuildHigaitouList()
|
||||
BuildHigaitouList = dropdownList
|
||||
End Function
|
||||
|
||||
' Create MonthAmountKbn (AX) dropdown
|
||||
Public Function BuildMonthAmountKbnList()
|
||||
Dim z3Cache As Object: Set z3Cache = GetCache("Z3")
|
||||
|
||||
Dim dropdownList As String
|
||||
Dim key As Variant
|
||||
For Each key In z3Cache.Keys
|
||||
Dim displayText As String
|
||||
displayText = MakeSelect(key, z3Cache(key)(0))
|
||||
If dropdownList = "" Then
|
||||
dropdownList = displayText
|
||||
Else
|
||||
dropdownList = dropdownList & "," & displayText
|
||||
End If
|
||||
Next key
|
||||
BuildMonthAmountKbnList = dropdownList
|
||||
End Function
|
||||
|
||||
' Create Kanshoku (BC) dropdown
|
||||
Public Function BuildKanshokuList()
|
||||
Dim o2Cache As Object: Set o2Cache = GetCache("O2")
|
||||
|
||||
51
src/sh/tuk/module/Common_Shape.bas
Normal file
51
src/sh/tuk/module/Common_Shape.bas
Normal file
@@ -0,0 +1,51 @@
|
||||
Attribute VB_Name = "Common_Shape"
|
||||
Option Explicit
|
||||
|
||||
' ================= 通用排版引擎(仅调整位置) =================
|
||||
|
||||
Public Sub AlignIconsByCenter(sheetName As String, anchorAddr As String, _
|
||||
iconArr As Variant, gapPt As Double)
|
||||
Dim ws As Worksheet
|
||||
Dim anchor As Range
|
||||
Dim shp As Shape
|
||||
Dim i As Long
|
||||
Dim shapeCount As Long
|
||||
|
||||
On Error Resume Next
|
||||
Set ws = ThisWorkbook.Worksheets(sheetName)
|
||||
On Error GoTo 0
|
||||
If ws Is Nothing Then Exit Sub
|
||||
|
||||
Set anchor = ws.Range(anchorAddr)
|
||||
shapeCount = UBound(iconArr) - LBound(iconArr) + 1
|
||||
|
||||
' 第一个图标左边对齐B3左边
|
||||
Dim curX As Double: curX = anchor.Left
|
||||
Dim prevX As Double: prevX = 0
|
||||
Dim cy As Double: cy = anchor.Top + anchor.Height / 2
|
||||
|
||||
Application.ScreenUpdating = False
|
||||
For i = LBound(iconArr) To UBound(iconArr)
|
||||
Set shp = ws.Shapes(iconArr(i))
|
||||
shp.Placement = xlFreeFloating
|
||||
shp.Left = curX
|
||||
shp.Top = cy - shp.Height / 2
|
||||
If i = LBound(iconArr) Then
|
||||
Debug.Print iconArr(i) & ": left=" & curX & ", width=" & shp.Width
|
||||
Else
|
||||
Debug.Print iconArr(i) & ": left=" & curX & ", gap=" & (curX - prevX) & ", width=" & shp.Width
|
||||
End If
|
||||
prevX = curX + shp.Width
|
||||
curX = curX + shp.Width + gapPt
|
||||
Next i
|
||||
Application.ScreenUpdating = True
|
||||
End Sub
|
||||
|
||||
' ================= 你的专属调用入口 =================
|
||||
Sub RunAlignForMySheet()
|
||||
AlignIconsByCenter _
|
||||
sheetName:="M1", _
|
||||
anchorAddr:="B3", _
|
||||
iconArr:=Array("input", "check", "output", "sort", "filter", "fit", "load"), _
|
||||
gapPt:=10
|
||||
End Sub
|
||||
@@ -21,37 +21,42 @@
|
||||
Const CSHAINNO_COL As String = "C"
|
||||
Const ADDRESS1_COL As String = "I"
|
||||
Const ADDRESS2_COL As String = "J"
|
||||
Const MMONTH_AMOUNT_KBN_COL As String = "BB"
|
||||
|
||||
Private Function KUKAN_CODE_COLS() As Variant
|
||||
KUKAN_CODE_COLS = Array(19, 26, 33, 40) ' S, Z, AG, AN
|
||||
KUKAN_CODE_COLS = Array(19, 27, 35, 43) ' S, AA, AI, AQ
|
||||
End Function
|
||||
|
||||
Private Function KUKAN_TRANSPORT_COLS() As Variant
|
||||
KUKAN_TRANSPORT_COLS = Array(20, 27, 34, 41) ' T, AA, AH, AO
|
||||
KUKAN_TRANSPORT_COLS = Array(20, 28, 36, 44) ' T, AB, AJ, AR
|
||||
End Function
|
||||
|
||||
Private Function KUKAN_STATION_COLS() As Variant
|
||||
KUKAN_STATION_COLS = Array(21, 28, 35, 42) ' U, AB, AI, AP
|
||||
KUKAN_STATION_COLS = Array(21, 29, 37, 45) ' U, AC, AK, AS
|
||||
End Function
|
||||
|
||||
Private Function KUKAN_ARRIVAL_COLS() As Variant
|
||||
KUKAN_ARRIVAL_COLS = Array(22, 29, 36, 43) ' V, AC, AJ, AQ
|
||||
KUKAN_ARRIVAL_COLS = Array(22, 30, 38, 46) ' V, AD, AL, AT
|
||||
End Function
|
||||
|
||||
Private Function KUKAN_TICKET_COLS() As Variant
|
||||
KUKAN_TICKET_COLS = Array(23, 30, 37, 44) ' W, AD, AK, AR
|
||||
KUKAN_TICKET_COLS = Array(23, 31, 39, 47) ' W, AE, AM, AU
|
||||
End Function
|
||||
|
||||
Private Function KUKAN_CODE2_COLS() As Variant
|
||||
KUKAN_CODE2_COLS = Array(24, 31, 38, 45) ' X, AE, AL, AS
|
||||
KUKAN_CODE2_COLS = Array(24, 32, 40, 48) ' X, AF, AN, AV
|
||||
End Function
|
||||
|
||||
Private Function KUKAN_TEIKI_COLS() As Variant
|
||||
KUKAN_TEIKI_COLS = Array(25, 33, 41, 49) ' Y, AG, AO, AW
|
||||
End Function
|
||||
|
||||
Private Function KUKAN_START_DAY_COLS() As Variant
|
||||
KUKAN_START_DAY_COLS = Array(25, 32, 39, 46) ' Y, AF, AM, AT
|
||||
KUKAN_START_DAY_COLS = Array(26, 34, 42, 50) ' Z, AH, AP, AX
|
||||
End Function
|
||||
|
||||
Private Function DATE_COLS() As Variant
|
||||
DATE_COLS = Array(4, 5, 6, 25, 32, 39, 46, 51, 54) ' D, E, F, Y, AF, AM, AT, AY, BB
|
||||
DATE_COLS = Array(4, 5, 6, 26, 34, 42, 50, 56, 59) ' D, E, F, Z, AH, AP, AX, BC, BF
|
||||
End Function
|
||||
|
||||
Private Function NUMBER_COLS() As Variant
|
||||
@@ -89,11 +94,10 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
.Columns("F"), _
|
||||
.Columns("G"), _
|
||||
.Columns("I"), _
|
||||
.Columns("S:W"), _
|
||||
.Columns("Z:AD"), _
|
||||
.Columns("AG:AK"), _
|
||||
.Columns("AN:AR"), _
|
||||
.Columns("BB") _
|
||||
.Columns("S:X"), _
|
||||
.Columns("AA:AF"), _
|
||||
.Columns("AI:AN"), _
|
||||
.Columns("AQ:AV") _
|
||||
)
|
||||
End With
|
||||
Dim intersectRng As Range: Set intersectRng = Application.Intersect(Target, watchArea)
|
||||
@@ -167,7 +171,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Transport column changes (T, AA, AH, AO) ===
|
||||
' === Transport column changes (T, AB, AJ, AR) ===
|
||||
idx = GetIdx(Target.Column, KUKAN_TRANSPORT_COLS)
|
||||
If idx >= 0 Then
|
||||
Dim cellT As Range
|
||||
@@ -180,7 +184,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Station column changes (U, AB, AI, AP) ===
|
||||
' === Station column changes (U, AC, AK, AS) ===
|
||||
idx = GetIdx(Target.Column, KUKAN_STATION_COLS)
|
||||
If idx >= 0 Then
|
||||
Dim cellU As Range
|
||||
@@ -193,7 +197,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Arrival column changes (V, AC, AJ, AQ) ===
|
||||
' === Arrival column changes (V, AD, AL, AT) ===
|
||||
idx = GetIdx(Target.Column, KUKAN_ARRIVAL_COLS)
|
||||
If idx >= 0 Then
|
||||
Dim cellV As Range
|
||||
@@ -210,7 +214,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Kukan code column changes (S, Z, AG, AN) ===
|
||||
' === Kukan code column changes (S, AA, AI, AQ) ===
|
||||
idx = GetIdx(Target.Column, KUKAN_CODE_COLS)
|
||||
If idx >= 0 Then
|
||||
Dim cellK As Range
|
||||
@@ -219,7 +223,7 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Ticket column changes (W, AD, AK, AR) ===
|
||||
' === Ticket column changes (W, AE, AM, AU) ===
|
||||
idx = GetIdx(Target.Column, KUKAN_TICKET_COLS)
|
||||
If idx >= 0 Then
|
||||
Dim cellTi As Range
|
||||
@@ -228,7 +232,22 @@ Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
Dim code2Col As Long: code2Col = KUKAN_CODE2_COLS(idx)
|
||||
Me.Cells(cellTi.Row, code2Col).ClearContents
|
||||
Me.Cells(cellTi.Row, code2Col).Validation.Delete
|
||||
Call CreateM2CodeDropdown(cellTi.Row, KUKAN_CODE_COLS(idx), KUKAN_TICKET_COLS(idx), code2Col)
|
||||
' Also clear teiki column
|
||||
Dim teikiCol As Long: teikiCol = KUKAN_TEIKI_COLS(idx)
|
||||
Me.Cells(cellTi.Row, teikiCol).ClearContents
|
||||
Me.Cells(cellTi.Row, teikiCol).Validation.Delete
|
||||
Call BuildM2CodeDropdown(cellTi.Row, KUKAN_CODE_COLS(idx), KUKAN_TICKET_COLS(idx), code2Col)
|
||||
Next
|
||||
End If
|
||||
|
||||
' === Code2 column changes (X, AF, AN, AV) ===
|
||||
idx = GetIdx(Target.Column, KUKAN_CODE2_COLS)
|
||||
If idx >= 0 Then
|
||||
Dim cellCode2 As Range
|
||||
For Each cellCode2 In Target
|
||||
If Trim(cellCode2.Value) <> "" Then
|
||||
Call CreateTeikiDropdown(cellCode2.Row, idx)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
@@ -266,7 +285,22 @@ Private Sub Refresh(ws As Worksheet, ByVal startRow As Long, ByVal lastDataRow A
|
||||
Call BuildAddress2Dropdown(r, cshainno)
|
||||
Call ReFillAddress2(r, cshainno)
|
||||
Call RebuildDropdowns(r)
|
||||
|
||||
Call ReFillFromDropdowns(r)
|
||||
|
||||
' Refresh teiki dropdowns for all 4 sections
|
||||
Dim idx As Long
|
||||
For idx = 0 To 3
|
||||
Dim kukanCode As String: kukanCode = Trim(Me.Cells(r, KUKAN_CODE_COLS(idx)).Value)
|
||||
Dim kenshu As String: kenshu = GetCode(Trim(Me.Cells(r, KUKAN_TICKET_COLS(idx)).Value))
|
||||
Dim code As String: code = GetCode(Trim(Me.Cells(r, KUKAN_CODE2_COLS(idx)).Value))
|
||||
Call BuildM2CodeDropdown(r, KUKAN_CODE_COLS(idx), KUKAN_TICKET_COLS(idx), KUKAN_CODE2_COLS(idx))
|
||||
Call ReFillM2CodeDropdown(r, KUKAN_CODE_COLS(idx), KUKAN_TICKET_COLS(idx), KUKAN_CODE2_COLS(idx))
|
||||
If kukanCode <> "" And kenshu <> "" And code <> "" Then
|
||||
Dim teikiColIndex As Long: teikiColIndex = KUKAN_TEIKI_COLS(idx)
|
||||
Call BuildTeikiDropdown(r, kukanCode, kenshu, code, ColLetter(teikiColIndex))
|
||||
End If
|
||||
Next idx
|
||||
Next r
|
||||
|
||||
Application.EnableEvents = True
|
||||
@@ -281,16 +315,15 @@ Private Sub RebuildDropdowns(ByVal rowNum As Long)
|
||||
Dim dropdowns As Variant
|
||||
dropdowns = Array( _
|
||||
Array("T", "BuildTransportList"), _
|
||||
Array("AA", "BuildTransportList"), _
|
||||
Array("AH", "BuildTransportList"), _
|
||||
Array("AO", "BuildTransportList"), _
|
||||
Array("AB", "BuildTransportList"), _
|
||||
Array("AJ", "BuildTransportList"), _
|
||||
Array("AR", "BuildTransportList"), _
|
||||
Array("G", "BuildTodokeList"), _
|
||||
Array("M", "BuildOufukuList"), _
|
||||
Array("N", "BuildKoutaiList"), _
|
||||
Array("AU", "BuildKetteiList"), _
|
||||
Array("AW", "BuildHigaitouList"), _
|
||||
Array("AX", "BuildMonthAmountKbnList"), _
|
||||
Array("BC", "BuildKanshokuList") _
|
||||
Array("AY", "BuildKetteiList"), _
|
||||
Array("BA", "BuildHigaitouList"), _
|
||||
Array("BG", "BuildKanshokuList") _
|
||||
)
|
||||
|
||||
Dim i As Long
|
||||
@@ -302,22 +335,32 @@ Private Sub RebuildDropdowns(ByVal rowNum As Long)
|
||||
.InCellDropdown = True
|
||||
End With
|
||||
Next i
|
||||
|
||||
Call BuildDropdownFromCacheNamedRange(Me, MMONTH_AMOUNT_KBN_COL, rowNum, "Z3")
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ReFillFromDropdowns(ByVal rowNum As Long)
|
||||
|
||||
Dim z3Cache As Object: Set z3Cache = GetCache("Z3")
|
||||
Dim valueStrMonthAmountKbn As String: valueStrMonthAmountKbn = Trim(Me.Cells(rowNum, MMONTH_AMOUNT_KBN_COL).Value)
|
||||
Dim monthAmountKbn As String: monthAmountKbn = GetCode(valueStrMonthAmountKbn)
|
||||
If z3Cache.Exists(monthAmountKbn) Then
|
||||
Me.Cells(rowNum, MMONTH_AMOUNT_KBN_COL).Value = MakeSelect(monthAmountKbn, z3Cache(monthAmountKbn)(0))
|
||||
End If
|
||||
|
||||
Dim dropdowns As Variant
|
||||
dropdowns = Array( _
|
||||
Array("T", "BuildTransportList"), _
|
||||
Array("AA", "BuildTransportList"), _
|
||||
Array("AH", "BuildTransportList"), _
|
||||
Array("AO", "BuildTransportList"), _
|
||||
Array("AB", "BuildTransportList"), _
|
||||
Array("AJ", "BuildTransportList"), _
|
||||
Array("AR", "BuildTransportList"), _
|
||||
Array("G", "BuildTodokeList"), _
|
||||
Array("M", "BuildOufukuList"), _
|
||||
Array("N", "BuildKoutaiList"), _
|
||||
Array("AU", "BuildKetteiList"), _
|
||||
Array("AW", "BuildHigaitouList"), _
|
||||
Array("AX", "BuildMonthAmountKbnList"), _
|
||||
Array("BC", "BuildKanshokuList") _
|
||||
Array("AY", "BuildKetteiList"), _
|
||||
Array("BA", "BuildHigaitouList"), _
|
||||
Array("BG", "BuildKanshokuList") _
|
||||
)
|
||||
|
||||
Dim i As Long
|
||||
@@ -645,9 +688,9 @@ Private Sub ClearKukanValidation(ByVal rowNum As Long, ByVal col As Long)
|
||||
End Sub
|
||||
|
||||
' Create dropdown from M2 cache: get code (J) list for kukanCode + kanshu
|
||||
Private Sub CreateM2CodeDropdown(ByVal rowNum As Long, ByVal kukanCodeCol As Long, ByVal kanshuCol As Long, ByVal codeCol As Long)
|
||||
Private Sub BuildM2CodeDropdown(ByVal rowNum As Long, ByVal kukanCodeCol As Long, ByVal kanshuCol As Long, ByVal codeCol As Long)
|
||||
Dim m2Cache As Object: Set m2Cache = GetCache("M2")
|
||||
|
||||
|
||||
Dim kukanCode As String: kukanCode = Trim(Me.Cells(rowNum, kukanCodeCol).Value)
|
||||
Dim kanshuStr As String: kanshuStr = Trim(Me.Cells(rowNum, kanshuCol).Value)
|
||||
If kukanCode = "" Or kanshuStr = "" Then Exit Sub
|
||||
@@ -661,10 +704,12 @@ Private Sub CreateM2CodeDropdown(ByVal rowNum As Long, ByVal kukanCodeCol As Lon
|
||||
Dim innermostDict As Object: Set innermostDict = innerDict(kanshu)
|
||||
Dim code As Variant
|
||||
For Each code In innermostDict.Keys
|
||||
Dim infoDict As Object: Set infoDict = innermostDict(code)
|
||||
Dim codeName As String: codeName = infoDict("name")
|
||||
If dropdownList = "" Then
|
||||
dropdownList = MakeSelect(code, innermostDict(code))
|
||||
dropdownList = MakeSelect(code, codeName)
|
||||
Else
|
||||
dropdownList = dropdownList & "," & code
|
||||
dropdownList = dropdownList & "," & MakeSelect(code, codeName)
|
||||
End If
|
||||
Next code
|
||||
End If
|
||||
@@ -680,25 +725,44 @@ Private Sub CreateM2CodeDropdown(ByVal rowNum As Long, ByVal kukanCodeCol As Lon
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ReFillM2CodeDropdown(ByVal rowNum As Long, ByVal kukanCodeCol As Long, ByVal kanshuCol As Long, ByVal codeCol As Long)
|
||||
Dim m2Cache As Object: Set m2Cache = GetCache("M2")
|
||||
|
||||
Dim kukanCode As String: kukanCode = Trim(Me.Cells(rowNum, kukanCodeCol).Value)
|
||||
Dim kenshu As String: kenshu = GetCode(Trim(Me.Cells(rowNum, kanshuCol).Value))
|
||||
If kukanCode = "" Or kenshu = "" Then
|
||||
Me.Cells(rowNum, codeCol).ClearContents
|
||||
Me.Cells(rowNum, codeCol).Validation.Delete
|
||||
Me.Cells(rowNum, codeCol).Interior.Color = vbWhite
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim code As String: code = GetCode(Trim(Me.Cells(rowNum, codeCol).Value))
|
||||
If m2Cache.Exists(kukanCode) Then
|
||||
Dim innerDict As Object: Set innerDict = m2Cache(kukanCode)
|
||||
If innerDict.Exists(kenshu) Then
|
||||
Dim innermostDict As Object: Set innermostDict = innerDict(kenshu)
|
||||
If innermostDict.Exists(code) Then
|
||||
Dim infoDict As Object: Set infoDict = innermostDict(code)
|
||||
Dim codeName As String: codeName = infoDict("name")
|
||||
Me.Cells(rowNum, codeCol).Value = MakeSelect(code, codeName)
|
||||
End IF
|
||||
End If
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
' Clear row data and validation
|
||||
Private Sub ClearRowData(ByVal rowNum As Long)
|
||||
Dim sheetConfDict As Object: Set sheetConfDict = GetSheetConfig()
|
||||
Dim sheetConf As Object: Set sheetConf = sheetConfDict(Me.CodeName)
|
||||
|
||||
Dim startCol As String: startCol = sheetConf("StartCol")
|
||||
Dim startCol As String: startCol = sheetConf("ErrorCol")
|
||||
Dim endCol As String: endCol = sheetConf("EndCol")
|
||||
Dim errorCol As String: errorCol = sheetConf("ErrorCol")
|
||||
|
||||
Me.Range(Me.Cells(rowNum, startCol), Me.Cells(rowNum, endCol)).ClearContents
|
||||
Me.Range(Me.Cells(rowNum, startCol), Me.Cells(rowNum, endCol)).Validation.Delete
|
||||
Me.Range(Me.Cells(rowNum, startCol), Me.Cells(rowNum, endCol)).Interior.Color = vbWhite
|
||||
Me.Cells(rowNum, errorCol).ClearContents
|
||||
|
||||
Dim clearValidationCols As Variant
|
||||
clearValidationCols = Array("I", "J", "U", "V", "X", "AB", "AC", "AE", "AI", "AJ", "AL", "AP", "AQ", "AS")
|
||||
Dim col As Variant
|
||||
For Each col In clearValidationCols
|
||||
Me.Range(col & rowNum).Validation.Delete
|
||||
Next col
|
||||
End Sub
|
||||
|
||||
' Validation logic
|
||||
@@ -717,7 +781,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
|
||||
|
||||
' Required columns: C-G, K-N, AW
|
||||
Dim requiredCols As Variant
|
||||
requiredCols = Array("C", "D", "E", "F", "G", "L", "M", "N", "AW")
|
||||
requiredCols = Array("C", "D", "E", "F", "G", "L", "M", "N", "BA")
|
||||
Dim col As Variant
|
||||
For Each col In requiredCols
|
||||
If Trim(Me.Range(col & rowNum).Value & "") = "" Then
|
||||
@@ -847,6 +911,7 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
|
||||
' Validate KUKAN_TICKET_COLS and KUKAN_CODE2_COLS
|
||||
Dim ticketCol As Long: ticketCol = KUKAN_TICKET_COLS(kukanIdx)
|
||||
Dim code2Col As Long: code2Col = KUKAN_CODE2_COLS(kukanIdx)
|
||||
Dim teikiCol As Long: teikiCol = KUKAN_TEIKI_COLS(kukanIdx)
|
||||
Dim ticketVal As String: ticketVal = GetCode(Trim(Me.Cells(rowNum, ticketCol).Value))
|
||||
Dim code2Val As String: code2Val = GetCode(Trim(Me.Cells(rowNum, code2Col).Value))
|
||||
Dim ticketLetter As String: ticketLetter = Split(Me.Cells(1, ticketCol).Address, "$")(1)
|
||||
@@ -886,6 +951,14 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
|
||||
Me.Cells(rowNum, errorCol).Value = code2Letter & " column is invalid"
|
||||
Me.Range(code2Letter & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
Exit Sub
|
||||
Else
|
||||
Dim teikiValue As String: teikiValue = Trim(Me.Cells(rowNum, teikiCol).Value)
|
||||
If ticketVal = "1" And teikiValue = "" Then
|
||||
Dim teikiLetter As String: teikiLetter = ColLetter(teikiCol)
|
||||
Me.Cells(rowNum, errorCol).Value = teikiLetter & " column is required"
|
||||
Me.Range(teikiLetter & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -925,33 +998,33 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
|
||||
|
||||
' Validate H, BB, BC columns
|
||||
Dim linkCellValue As String: linkCellValue = Me.Cells(3, "H").Value
|
||||
Dim ColBB As String: ColBB = "BB"
|
||||
Dim ColBC As String: ColBC = "BC"
|
||||
Dim valBB As String: valBB = Trim(Me.Cells(rowNum, ColBB).Value)
|
||||
Dim valBC As String: valBC = Trim(Me.Cells(rowNum, ColBC).Value)
|
||||
Dim ColBF As String: ColBF = "BF"
|
||||
Dim ColBG As String: ColBG = "BG"
|
||||
Dim valBF As String: valBF = Trim(Me.Cells(rowNum, ColBF).Value)
|
||||
Dim valBG As String: valBG = Trim(Me.Cells(rowNum, ColBG).Value)
|
||||
|
||||
If linkCellValue = "1" Then
|
||||
' If code = "1", BB and BC must be empty
|
||||
If valBB <> "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E005", ColBB & rowNum)
|
||||
Me.Range(ColBB & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
If valBF <> "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E005", ColBF & rowNum)
|
||||
Me.Range(ColBF & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
Exit Sub
|
||||
End If
|
||||
If valBC <> "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E005", ColBC & rowNum)
|
||||
Me.Range(ColBC & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
If valBG <> "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E005", ColBG & rowNum)
|
||||
Me.Range(ColBG & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
Exit Sub
|
||||
End If
|
||||
ElseIf linkCellValue = "2" Then
|
||||
' If code = "2", BB and BC must have value
|
||||
If valBB = "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E002", ColBB & rowNum)
|
||||
Me.Range(ColBB & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
If valBF = "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E002", ColBF & rowNum)
|
||||
Me.Range(ColBF & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
Exit Sub
|
||||
End If
|
||||
If valBC = "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E002", ColBC & rowNum)
|
||||
Me.Range(ColBC & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
If valBG = "" Then
|
||||
Me.Cells(rowNum, errorCol).Value = GetErrorMsg("E002", ColBG & rowNum)
|
||||
Me.Range(ColBG & rowNum).Interior.Color = RGB(255, 0, 0)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
@@ -962,3 +1035,57 @@ Public Sub Validate(ws As Worksheet, ByVal rowNum As Long, ByVal lastDataRow As
|
||||
ErrHandler:
|
||||
lastErrorMsg = Err.Description
|
||||
End Sub
|
||||
|
||||
' Create teiki dropdown based on M2 cache
|
||||
Private Sub CreateTeikiDropdown(ByVal row As Long, ByVal idx As Long)
|
||||
' Get kukanCode from KUKAN_CODE_COLS
|
||||
Dim kukanCol As Long: kukanCol = KUKAN_CODE_COLS(idx)
|
||||
Dim kukanCode As String: kukanCode = Trim(Me.Cells(row, kukanCol).Value)
|
||||
' Get kenshu from KUKAN_TICKET_COLS
|
||||
Dim kenshu As String: kenshu = GetCode(Trim(Me.Cells(row, KUKAN_TICKET_COLS(idx)).Value))
|
||||
' Get code2 from KUKAN_CODE2_COLS
|
||||
Dim code As String: code = GetCode(Trim(Me.Cells(row, KUKAN_CODE2_COLS(idx)).Value))
|
||||
|
||||
If kukanCode = "" Or kenshu = "" Or code = "" Then Exit Sub
|
||||
If Not kenshu = "1" Then Exit Sub
|
||||
|
||||
Dim teikiColIndex As Long: teikiColIndex = KUKAN_TEIKI_COLS(idx)
|
||||
Call BuildTeikiDropdown(row, kukanCode, kenshu, code, ColLetter(teikiColIndex))
|
||||
End Sub
|
||||
|
||||
Private Sub BuildTeikiDropdown(ByVal rowNum As Long, ByVal kukanCode As String, ByVal kenshu As String, ByVal code As String, ByVal targetCell As String)
|
||||
Dim M2Cache As Object: Set M2Cache = GetCache("M2")
|
||||
Dim kenshuDict As Object: Set kenshuDict = M2Cache(kukanCode)
|
||||
Dim codeDict As Object: Set codeDict = kenshuDict(kenshu)
|
||||
Dim teikiArray As Object: Set teikiArray = codeDict(code)
|
||||
|
||||
If teikiArray Is Nothing Then Exit Sub
|
||||
If Not teikiArray.Exists("teikikikanNum") Then Exit Sub
|
||||
|
||||
Dim teikiList As Variant: teikiList = teikiArray("teikikikanNum")
|
||||
If Not IsArray(teikiList) Then Exit Sub
|
||||
If UBound(teikiList) < LBound(teikiList) Then Exit Sub
|
||||
|
||||
' Build dropdown list
|
||||
Dim dropdownList As String: dropdownList = ""
|
||||
Dim i As Long
|
||||
For i = LBound(teikiList) To UBound(teikiList)
|
||||
Dim val As String: val = CStr(teikiList(i))
|
||||
If val <> "" Then
|
||||
If dropdownList = "" Then
|
||||
dropdownList = val
|
||||
Else
|
||||
dropdownList = dropdownList & "," & val
|
||||
End If
|
||||
End If
|
||||
Next i
|
||||
|
||||
If dropdownList <> "" Then
|
||||
With Me.Range(targetCell & rowNum).Validation
|
||||
.Delete
|
||||
.Add Type:=xlValidateList, Formula1:=dropdownList
|
||||
.IgnoreBlank = True
|
||||
.InCellDropdown = True
|
||||
End With
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -338,7 +338,7 @@ Private Sub FillKFromJ(ByVal ws As Worksheet, ByVal rowNum As Long)
|
||||
ws.Range("K" & rowNum).Value = Trim(cacheVal(0))
|
||||
End If
|
||||
|
||||
Select Case iValue
|
||||
Select Case kenshu
|
||||
Case "1"
|
||||
Exit Sub
|
||||
Case "2"
|
||||
|
||||
Reference in New Issue
Block a user