VBA code Required For Deleting A Folder then Copying Files From Another Folder

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,516
Office Version
  1. 2016
Platform
  1. Windows
Hello Friends,

I need a VBA Code which could do the following if possible

1) The code should first go to D:\ Drive there might be a folder starting with the name OneDrive Backup followed by some other text like date and time etc & delete that folder. If there is no folder in D:\ Drive starting with the name OneDrive Backup then code should jump to the next step

2) Next the code should create a new folder in D:\ Drive and name it OneDrive Backup followed by date & time (like OneDrive Backup 10-Mar-24 10:00 PM)

3) Next go to a folder C:\OneDrive - open that folder and copy everything from that folder and paste it in the newly created folder i.e. D:\OneDrive Backup

Regards,

Humayun
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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