save all workbooks

jaypatel

Active Member
Joined
Nov 25, 2002
Messages
389
Hi,

Is there a piece of code that will save all workbooks that are open?

So if I have 5 spreadsheets that is open, can all of them be saved one after the other.

Cheers

Jay
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try:
Code:
Sub CloseAll()
Dim wbk As Workbook
For Each wbk In Workbooks
    Application.DisplayAlerts = False
           wbk.Close SaveChanges:=False
    Application.DisplayAlerts = True
Next wbk
End Sub

Or simply:
Code:
Workbooks.Close
(displays dialogs)
Martin
 
Upvote 0
From MS KB: XL2000: How to Programmatically Save All Open Workbooks

Code:
Sub SaveAll()
    ' Store the Activeworkbook in a variable.
    Set aw = ActiveWorkbook
        For Each wb In Workbooks
            If wb.Path <> "" Then ' Save file if it has been saved
                                  ' previously
                wb.Save
            Else  ' If not previously saved, activate and show the
                  ' Save As dialog box.
                wb.Activate
                Application.Dialogs(xlDialogSaveAs).Show
            End If
        Next
    aw.Activate   ' Activate the original Activeworkbook.
End Sub

HTH
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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