Link to home
Start Free TrialLog in
Avatar of sharepoint0520
sharepoint0520

asked on

How to move all files from subfolders to one folder by VBA code ?

Experts,

 I have one Folders and it has some sub folders and Subfolder has files like excel , word etc... I would like to have one small program when i set source and destination folder and run the script to get all only excel files to Destination folder.

Please let me know if you need more clarification..

Thanks,
Avatar of Temody
Temody
Flag of Egypt image

you can use this command
also you can save it as a batch file to run in scheduled time

SET MoveDirSource=c:\source
SET MoveDirDestination=d:\destination
ROBOCOPY "%MoveDirSource%" "%MoveDirDestination%" /MOVE /E

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry i don't see (only excel files)
please try this

SET MoveDirSource=c:\source
SET MoveDirDestination=d:\destnation
ROBOCOPY *.xls* "%MoveDirSource%" "%MoveDirDestination%" /MOVE /E

Open in new window

Avatar of sharepoint0520
sharepoint0520

ASKER

Hi,

 Can you please write codes in Module or any Excel form ? Is it possible to attach Excel file for you guys ? I am not clear to use Function.
NVIT,

 How to use this function in Module ? I would like to Button to click to move files. Any advice?
I got it.