Help making a loop end

gschwint

Board Regular
Joined
Aug 17, 2004
Messages
121
I have the following code set to run before a workbook close event and it never gets out of the loop:

Code:
Sub HideSheets()
Dim sht As Object
Dim saveresponse As Boolean

Application.ScreenUpdating = False

ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVisible

For Each sht In ThisWorkbook.Sheets

If sht.Name <> "Macros Disabled" Then sht.Visible = xlSheetVeryHidden

Next sht

Do Until saverespone = True
MsgBox "You Must save a copy of this file before exiting the spreadsheet otherwise it may not function correctly when opening the spreadsheet again." & vbNewLine & vbNewLine & "This may up to 1 minute or more depending on your computer speed.", vbCritical, "Saving the File is Required"
saveresponse = Application.Dialogs(xlDialogSaveAs).Show
Loop

Application.Quit

End Sub

Any help?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Ciao gschwint,
if the use of the loop with the syntax

Do Until saverespone = True
...
Loop


is not mandatory, you can use the following:
...
Do While Not saveresponse
saveresponse = False
Do While Not saveresponse
MsgBox ...
saveresponse = Application.Dialogs(xlDialogSaveAs).Show
Loop
...

:nya: :nya:
 
Upvote 0
I had to add an additional "loop" to the bottom of the code but after that it worked like a charm. Thanks much.

George
 
Upvote 0

Forum statistics

Threads
1,222,315
Messages
6,165,301
Members
451,950
Latest member
WH2000

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