Slow on exit

wmtsub

Active Member
Joined
Jun 20, 2018
Messages
322
This macro will add 30 seconds to the close process. I can not see why it would take that long.
Any ideas?


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Sheets("START").Visible = xlSheetVisible
Application.WindowState = xlMaximized
For Each ws In Worksheets
If ws.Name <> "START" Then
ws.Visible = False
End If
Next ws
Application.ScreenUpdating = True
Application.ThisWorkbook.Saved = True
Application.Quit
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
.
Sheets("START").Visible = xlSheetVisible

Was the sheet START hidden previously ? If not, you don't need to make it visible prior to closing workbook.



Application.WindowState = xlMaximized

If, when the workbook opens, you have minimized the workbook, instead of using the command Application.WindowState ... use ThisWorkbook.WindowState. Then, when closing, you don't need
to use the above command to maximize the workbook.



For Each ws In Worksheets
If ws.Name <> "START" Then
ws.Visible = False
End If
Next ws

How many worksheets does your workbook have ? And since you are closing the workbook, why is it important to hide all those worksheets regardless of the number ?



Application.ThisWorkbook.Saved = True

Were there a lot of changes / edits to the workbook ? That could slow things down.



I have a personal project with nearly 1 million rows of data that could possibly be searched. It takes the workbook more time than I would like to open and close, but that
is due to the large amount of data on one of the sheets. How much data is contained in your workbook ?
 
Last edited:
Upvote 0
Logit - See Below.

Was the sheet START hidden previously ?
--- Yes.

Application.WindowState = xlMaximized
-
Done to insure that it is maximized when opening. Ill try "
ThisWorkbook.WindowState."
How many worksheets does your workbook have ?
11 and none are large.


And since you are closing the workbook, why is it important to hide all those worksheets regardless of the number ?
- Process to insure that macros are enabled to another user.

Application.ThisWorkbook.Saved = True -
to stope the prompt to be saved


Were there a lot of changes / edits to the workbook ?
No.
 
Upvote 0
.
Overall, there must be something else going on that is causing the issue .. other than your code. Your code shouldn't be the problem.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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