From da1df9337c033d8b40eec1bcff14dbd3bdf4b9de Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 22 May 2023 15:36:18 -0400 Subject: [PATCH] only close the workbook if there are no more tabs left --- PriceLists.bas | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PriceLists.bas b/PriceLists.bas index e9fe895..d5f7d5c 100644 --- a/PriceLists.bas +++ b/PriceLists.bas @@ -593,9 +593,14 @@ Sub build_price_level(plev As String) nws.Name = "Price list" Call paste_pretty(pl, nws, effdate, curr) Else - '---if the price list has no length, then close - nwb.Close - Exit Sub + '---if the price list has no length, then close the worksheet. + '---if it's the last worksheet, then close the whole workbook + If nwb.Sheets.Count = 1 Then + Call nwb.Close(False) + Exit Sub + Else + nws.Delete + End If End If Application.ScreenUpdating = True