rsrasc
08-16-2023, 01:04 PM
Hi all,
I'm using the following code to open the following workbooks. I need some help so I can save the files to the same location and close all of them.
I have tried several options but doesn't work for me.
I already have a code to save and close all the open excel files but on this one I just need the ones listed below.
Sub OpenUpFiles_5()
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\025 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\050 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\056 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\130 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\200 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\250 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\350 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\360 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\400 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\450 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\500 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\600 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Revenues\050 FY 2024 Revenues-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Revenues\130 FY 2024 Revenues-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Revenues\200 FY 2024 Revenues-SSE-Budget.xlsx"), UpdateLinks:=0
End Sub
For example, I'm using the following code to save and close all the open workbooks in excel but in my case I need to save and close specific files.
Hope this helps.
Regards,
rsrasc
Sub CloseAndSaveOpenWorkbooks_26()
Dim Wkb As Workbook
With Application
.ScreenUpdating = False
'Loop through the workbooks collection
For Each Wkb In Workbooks
With Wkb
'if the book is read-only don't save but close
If Not Wkb.ReadOnly Then
.Save
End If
'We save this workbook, but we don't close it _
because we will quit Excel at the end, _
Closing here leaves the app running, but no books
If .Name <> ThisWorkbook.Name Then
.Close
End If
End With
Next Wkb
.ScreenUpdating = True
.Quit 'Quit Excel
End With
End Sub
I'm using the following code to open the following workbooks. I need some help so I can save the files to the same location and close all of them.
I have tried several options but doesn't work for me.
I already have a code to save and close all the open excel files but on this one I just need the ones listed below.
Sub OpenUpFiles_5()
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\025 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\050 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\056 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\130 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\200 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\250 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\350 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\360 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\400 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\450 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\500 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Expenses\600 FY 2024 Expenses-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Revenues\050 FY 2024 Revenues-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Revenues\130 FY 2024 Revenues-SSE-Budget.xlsx"), UpdateLinks:=0
Workbooks.Open ("Z:\FY24 Budget\SSE Revenues\200 FY 2024 Revenues-SSE-Budget.xlsx"), UpdateLinks:=0
End Sub
For example, I'm using the following code to save and close all the open workbooks in excel but in my case I need to save and close specific files.
Hope this helps.
Regards,
rsrasc
Sub CloseAndSaveOpenWorkbooks_26()
Dim Wkb As Workbook
With Application
.ScreenUpdating = False
'Loop through the workbooks collection
For Each Wkb In Workbooks
With Wkb
'if the book is read-only don't save but close
If Not Wkb.ReadOnly Then
.Save
End If
'We save this workbook, but we don't close it _
because we will quit Excel at the end, _
Closing here leaves the app running, but no books
If .Name <> ThisWorkbook.Name Then
.Close
End If
End With
Next Wkb
.ScreenUpdating = True
.Quit 'Quit Excel
End With
End Sub