Issue: After run Macro vba, all worksheets auto closed without a warning message

anna99

New Member
Joined
Jan 8, 2021
Messages
26
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
  2. MacOS
  3. Web
Hi All,

I run a VBA code from my personal vba to open a closed workbook and then close this workbook with the code below. the issue is with all current active workbooks, when i close, there is no warning message "Do you want to save...." it's just closed without saving. until i close all current excel files and start excel again this issue will disappear. could you please help.

VBA Code:
Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.xls*),*xls*")
    If FileToOpen <> False Then
        Set OpenBook = Application.Workbooks.Open(FileToOpen)
        OpenBook.Sheets("Sheet1").Range("G1:L62").Copy
        mainWS.Range("G1").PasteSpecial xlPasteAll
        OpenBook.Close False
        
    End If
    Application.ScreenUpdating = True
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
That's because you aren't setting Application.DisplayAlerts = False back to Application.DisplayAlerts = True before the End Sub.
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top