Have approximately 85 workbooks that contains 10 worksheets each that are stored in
30 folders.
Objective: I need to delete all worksheets in the workbooks except three that is dependent on the
folder/subfolder. Then, I need to either automatically save the modified workbook with a name such as
"TheNameOfTheWorkbook_GeorgiaJan2008."
For example, the following location contains a workbook titled "StatementOfOper";
D:\Private\Georgia\2008-01
Therefore, I need to delete all worksheets for any other location except Georgia and save the workbook
in the current location as "D:\Private\Georgia\2008-01\StatementOfOper_GeorgiaJan2008."
Hopefully, this is possible? It would definitely eliminate the manual deletion of the folders which
is quite time intensive.
Currently working with the code below but would greatly appreciate any additional insight
regarding the most efficient method to accomplish the objective and how the code below should be
modified.
Also, any way I can initiate this from another worksheet - sort of like a "Control Sheet" instead of
manually opening each Excel workbook that needs to be modified?
Thanks in advance.
Sub DeleteAll()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ActiveWorkbook.Worksheets
If ws. Name = "GA ONE" Or ws.Name = "GA TWO" Or ws.Name = "GA THREE" Then
Else
ws.Visible = xlSheetVisible
ws.Delete
End If
Next ws
Application.DisplayAlerts = True
End Sub
30 folders.
Objective: I need to delete all worksheets in the workbooks except three that is dependent on the
folder/subfolder. Then, I need to either automatically save the modified workbook with a name such as
"TheNameOfTheWorkbook_GeorgiaJan2008."
For example, the following location contains a workbook titled "StatementOfOper";
D:\Private\Georgia\2008-01
Therefore, I need to delete all worksheets for any other location except Georgia and save the workbook
in the current location as "D:\Private\Georgia\2008-01\StatementOfOper_GeorgiaJan2008."
Hopefully, this is possible? It would definitely eliminate the manual deletion of the folders which
is quite time intensive.
Currently working with the code below but would greatly appreciate any additional insight
regarding the most efficient method to accomplish the objective and how the code below should be
modified.
Also, any way I can initiate this from another worksheet - sort of like a "Control Sheet" instead of
manually opening each Excel workbook that needs to be modified?
Thanks in advance.
Sub DeleteAll()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ActiveWorkbook.Worksheets
If ws. Name = "GA ONE" Or ws.Name = "GA TWO" Or ws.Name = "GA THREE" Then
Else
ws.Visible = xlSheetVisible
ws.Delete
End If
Next ws
Application.DisplayAlerts = True
End Sub