Move multiple files by vba

hdgfss

New Member
Joined
Aug 29, 2019
Messages
41
my files are located in C:\Users\WolfieeeStyle\Desktop\Files
i have to move 4 to 5 files(it can be more than this) from here C:\Users\WolfieeeStyle\Desktop\Files to C:\Users\WolfieeeStyle\Desktop
condition-check wheather my files are located in C:\Users\WolfieeeStyle\Desktop\Files if yes then move it to C:\Users\WolfieeeStyle\Desktop and if not then do nothing
Important- i will add the file names in the vba code so that if it is there then it will be moved ( i will put 7 or 8 files name in vba code or more)
 
Sir i just wanted to say that u have helped me with a folder part how to target the folder path
i understood that part but u have not guided me for the naming part of the files that i wanted to move(it can be multiple files)
No issues Sir
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Code:
Sub MACRO()    Set FSO = CreateObject("scripting.filesystemobject")
    FSO.MoveFile Source:="C:\Users\WolfieeeStyle\Desktop\Files\1.xlsb", Destination:="C:\Users\WolfieeeStyle\Desktop\"
    FSO.MoveFile Source:="C:\Users\WolfieeeStyle\Desktop\Files\2.xlsx", Destination:="C:\Users\WolfieeeStyle\Desktop\"
    




End Sub



I have this code it will move the file from that folder to another
what i need in this code is if files are present in that folder then move the file and if not then error should not come
what happened with this code is if files are prsent then the files are moved but if files are not present then i get error
and i dont want any error msg should come it should do the process as mentioned if criteria doesnt met then no error msg should come
 
Upvote 0
Both the codes supplied in the link I gave show how to check if a file exists.
 
Upvote 0
Sir i have the code
i have posted my code which can do the process, only one thing is pending in this code
Add something that cant create a msg that this file is not located or moved when it is not present and the problem will be solved automatically and i will learn a new thing and a remembering thing
New code is not required i think
plz manage this code in such a way that problem will be solved
So plz help
 
Upvote 0
Sir ur time is Precious
U have a personal Life
Professional life
and u spend ur time in helping us from 24hrs
Time is less,Work is More,For Fun and Relax also we need time
Make this post short
 
Upvote 0
On Error Resume Next
adding this line at the top of the code
This Problem is Solved
Thnx Alot all of u for giving ur Precious Time and Great Support to this Post
Have a Great Day Sir
 
Upvote 0

Forum statistics

Threads
1,224,760
Messages
6,180,816
Members
452,996
Latest member
nelsonsix66

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