Copying workbook to different folder and check for duplicate folder name

lakke2120

New Member
Joined
Aug 21, 2014
Messages
32
I have a code that copies workbook to a folder by cell value (A1) and month/year. It works fine but I need it to send a 2nd copy to another folder so I can have a back up. I would like to have the workbook copied to two separate folders with the same exact name (value in A1 and month/year). I would like to be able to check both folders to see if there are duplicate folders first and if so then overwrite. Can anyone please help. thank you

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If MsgBox("Would you like to back up file?", vbYesNo) = vbYes Then _

Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Sheets("SAP 1 PRINT ONLY").Range("A1").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = fName & " " & Format$(Date, "mmmm-yyyy")
' Change directory to suit your PC, including USER NAME
ChDir _
"S:\Active Individual Programs\Manager folder\New Programs\"
ActiveWorkbook.SaveAs Filename:=newFile

End If
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Answer found. Copy line -ActiveWorkbook.SaveAs Filename:=newFile and enter new path asfter SaveAs in quotes
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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