通勤認定エクセルツール対応11
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user