From 631e66242f0cc01bbb6940728b3a01bed713d650 Mon Sep 17 00:00:00 2001 From: Kenichiro NOGI Date: Mon, 14 Sep 2026 09:48:41 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20FilterTable/SorterTable=E3=82=92?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=83=85=E5=A0=B1=E3=82=B7=E3=83=BC=E3=83=88?= =?UTF-8?q?=E9=99=90=E5=AE=9A=E3=81=A7=E3=81=AA=E3=81=8F=E5=85=A8=E3=82=B7?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=8B=E3=82=89=E5=90=8D=E5=89=8D=E3=81=A7?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit defaultSh(基本情報シート)固定で探していたため、ユーザーが別シートにテーブルを配置した際にBuildViewFromSheetが見つけられずViewが常に空になっていた。 FindListObjectByNameを追加し、ブック内の全シートを走査してテーブル名で検索するよう変更。 Co-Authored-By: Claude Sonnet 5 --- .../vba-files/Module/Module1.bas | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas b/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas index 82f1402c..94d0f3bd 100644 --- a/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas +++ b/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas @@ -306,12 +306,26 @@ End Function 'e[uŒTēǂݎAAPINGXgViewp[^ɓnDictionarygݗĂB 'Z̐Έʒuɂ͈ˑȂie[uړĂ삷jBee[u1=ږA2=l/~ƂB 'FilterESorterƂ0̏ꍇNothingԂiViewp[^̂t^Ȃ߁j +'ubN̑SV[g𑖍Aw肵OExcele[u(ListObject)TB‚ȂNothingԂ +Function FindListObjectByName(ByVal tblName As String) As ListObject + Dim sh As Worksheet + Dim tbl As ListObject + For Each sh In ThisWorkbook.Worksheets + On Error Resume Next + Set tbl = sh.ListObjects(tblName) + On Error GoTo 0 + If Not tbl Is Nothing Then + Set FindListObjectByName = tbl + Exit Function + End If + Next sh + Set FindListObjectByName = Nothing +End Function + Function BuildViewFromSheet() As Object Dim colFilter As New Dictionary Dim filterTbl As ListObject - On Error Resume Next - Set filterTbl = defaultSh.ListObjects("FilterTable") - On Error GoTo 0 + Set filterTbl = FindListObjectByName("FilterTable") If Not filterTbl Is Nothing Then If Not filterTbl.DataBodyRange Is Nothing Then @@ -328,9 +342,7 @@ Function BuildViewFromSheet() As Object Dim colSorter As New Dictionary Dim sorterTbl As ListObject - On Error Resume Next - Set sorterTbl = defaultSh.ListObjects("SorterTable") - On Error GoTo 0 + Set sorterTbl = FindListObjectByName("SorterTable") If Not sorterTbl Is Nothing Then If Not sorterTbl.DataBodyRange Is Nothing Then