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

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,501
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,746
Messages
6,126,645
Members
449,325
Latest member
Hardey6ix

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