Save activeworkbook then move it to another file directory based on criteria in a specific cell.

cstuder

New Member
Joined
May 15, 2023
Messages
20
Office Version
  1. 2021
Platform
  1. Windows
I have two folders - In progress and completed. My original file is saved in the "in progress" file folder. Once the "in progress" file is done, I enter a Date Complete in cell J14. Then I save, close and then open file explorer to move the file to a "completed" folder.

Would someone be able to create a macro to automate this process? If a date is entered on the spreadsheet in J14 (criteria), the macro would save, close the file, then move it to the "completed" folder? I need the macro to skip all other files (located in the In Progress folder) if the Date Complete cell is blank. Thanks in advance.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
This macro should do everything you asked for. It assumes the "In progress" and "Completed" folders are at the same level.

VBA Code:
Public Sub Save_Completed_Workbook()

    With ActiveWorkbook
        If IsDate(.ActiveSheet.Range("J14").Value) Then
            'Save a copy of the active workbook in the Completed folder
            .SaveCopyAs .Path & "\..\Completed\" & .Name
            .Saved = True
            'Delete the original workbook (in the In Progress folder)
            .ChangeFileAccess xlReadOnly
            Kill .FullName
            'Close Excel
            Application.Quit
            .Close False
        End If
    End With
        
End Sub
 
Upvote 0
Solution
This macro should do everything you asked for. It assumes the "In progress" and "Completed" folders are at the same level.

VBA Code:
Public Sub Save_Completed_Workbook()

    With ActiveWorkbook
        If IsDate(.ActiveSheet.Range("J14").Value) Then
            'Save a copy of the active workbook in the Completed folder
            .SaveCopyAs .Path & "\..\Completed\" & .Name
            .Saved = True
            'Delete the original workbook (in the In Progress folder)
            .ChangeFileAccess xlReadOnly
            Kill .FullName
            'Close Excel
            Application.Quit
            .Close False
        End If
    End With
      
End Sub
Worked perfect! Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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