diff --git a/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas b/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas index 24f49de0..466795da 100644 --- a/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas +++ b/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas @@ -302,24 +302,48 @@ Private Function CollectionToArray(Byval col As Collection) As Variant End Function '****************************************************************************** -'{V[gFilter\(F2:G2oAF3ȍ~f[^)ESorter\(H2:I2oAH3ȍ~f[^)ǂݎA -'APINGXgViewp[^ɓnDictionarygݗĂB +'{V[ǵuFilterTablevuSorterTablevƂOExcele[uiListObjectj +'e[uŒTēǂݎAAPINGXgViewp[^ɓnDictionarygݗĂB +'Z̐Έʒuɂ͈ˑȂie[uړĂ삷jBee[u1=ږA2=l/~ƂB 'FilterESorterƂ0̏ꍇNothingԂiViewp[^̂t^Ȃ߁j Function BuildViewFromSheet() As Object Dim colFilter As New Dictionary - Dim r As Long - r = 3 - Do While Trim(defaultSh.Cells(r, "F").Value) <> "" - colFilter.Add defaultSh.Cells(r, "F").Value, "[" & Chr(34) & CStr(defaultSh.Cells(r, "G").Value) & Chr(34) & "]" - r = r + 1 - Loop + Dim filterTbl As ListObject + On Error Resume Next + Set filterTbl = defaultSh.ListObjects("FilterTable") + On Error GoTo 0 + + If Not filterTbl Is Nothing Then + If Not filterTbl.DataBodyRange Is Nothing Then + Dim r As Long + For r = 1 To filterTbl.DataBodyRange.Rows.count + Dim filterKey As String + filterKey = Trim(filterTbl.DataBodyRange.Cells(r, 1).Value) + If filterKey <> "" Then + colFilter.Add filterKey, "[" & Chr(34) & CStr(filterTbl.DataBodyRange.Cells(r, 2).Value) & Chr(34) & "]" + End If + Next r + End If + End If Dim colSorter As New Dictionary - r = 3 - Do While Trim(defaultSh.Cells(r, "J").Value) <> "" - colSorter.Add defaultSh.Cells(r, "J").Value, defaultSh.Cells(r, "K").Value - r = r + 1 - Loop + Dim sorterTbl As ListObject + On Error Resume Next + Set sorterTbl = defaultSh.ListObjects("SorterTable") + On Error GoTo 0 + + If Not sorterTbl Is Nothing Then + If Not sorterTbl.DataBodyRange Is Nothing Then + Dim r2 As Long + For r2 = 1 To sorterTbl.DataBodyRange.Rows.count + Dim sorterKey As String + sorterKey = Trim(sorterTbl.DataBodyRange.Cells(r2, 1).Value) + If sorterKey <> "" Then + colSorter.Add sorterKey, sorterTbl.DataBodyRange.Cells(r2, 2).Value + End If + Next r2 + End If + End If If colFilter.count = 0 And colSorter.count = 0 Then Set BuildViewFromSheet = Nothing