diff --git a/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas b/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas index 95384911..4f0f3331 100644 --- a/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas +++ b/XVBA/新版着工要因閲覧シート/vba-files/Module/Module1.bas @@ -106,9 +106,6 @@ Function runGetFlow() As Boolean If records Is Nothing Then Debug.Print "f[^擾ł܂ł" runGetFlow = False - ElseIf records.count = 0 Then - Debug.Print "f[^擾ł܂ł" - runGetFlow = False Else Call getRecordsDataToSheet(records, tableId & "G") t2 = Timer @@ -180,8 +177,17 @@ Function exportCSVDataToSheet(csvData As Variant, targetSheet As String) Set rows = ParseCsv(csvData) If rows.count <= 1 Then - MsgBox "f[^݂܂iwb_̂݁j: " & targetSheet, vbExclamation - Exit Function + Debug.Print "f[^0̂߁Ae[ũf[^NA܂: " & targetSheet + Dim tblEmpty As ListObject + On Error Resume Next + Set tblEmpty = ws.ListObjects(targetSheet) + On Error GoTo 0 + If Not tblEmpty Is Nothing Then + If Not tblEmpty.DataBodyRange Is Nothing Then + tblEmpty.DataBodyRange.ClearContents + End If + End If + Exit Function End If maxCols = 0 @@ -448,11 +454,6 @@ End Function Function getRecordsDataToSheet(records As Collection, targetSheet As String) Debug.Print "R[hV[gɏo͊Jn: " & targetSheet - If records.count = 0 Then - MsgBox "f[^݂܂: " & targetSheet, vbExclamation - Exit Function - End If - Dim ws As Worksheet On Error Resume Next Set ws = ThisWorkbook.Sheets(targetSheet) @@ -464,6 +465,20 @@ Function getRecordsDataToSheet(records As Collection, targetSheet As String) ws.Name = targetSheet End If + If records.count = 0 Then + Debug.Print "f[^0̂߁Ae[ũf[^NA܂: " & targetSheet + Dim tblEmpty As ListObject + On Error Resume Next + Set tblEmpty = ws.ListObjects(targetSheet) + On Error GoTo 0 + If Not tblEmpty Is Nothing Then + If Not tblEmpty.DataBodyRange Is Nothing Then + tblEmpty.DataBodyRange.ClearContents + End If + End If + Exit Function + End If + Dim flatRecords As New Collection Dim rec As Dictionary For Each rec In records