Private Sub LIST_Clear() Dim wb As Excel.Workbook Dim sh As Excel.Worksheet Dim LastRow As Integer Try wb = GetObject(ListFile) Catch ex As Exception
MessageBox.Show(ex.Message)
End Try sh = wb.Sheets(“Sheet1”) LastRow = sh.Cells(sh.Rows.Count, 1).end(Excel.XlDirection.xlUp).row Dim tl = sh.Cells(2, 1) Dim br = sh.Cells(LastRow + 1, 7) Dim wrange = sh.Range(tl, br) wrange.ClearContents() wb.Save() ←ここでExcelブックが壊れる(シートが参照できなくなります) wb.Close() End Sub