move specific files from directory to another without using cells
Hello Guys !
I have files are their names ("DATA_MONTLY" , "REPORTS RETURNS_MAR" , " INVOICES ARCHIVE") in this directory C:\Users\PC-MKK\Downloads\
what I want moving theses files to this directory D:\Users\PC-MKK\dektop\ MONTHLY FILES\ and if one of them is not existed then should pop up message " the file name is ..... not existed. I want to that without using cells just directly .
thanks
According to your explanation a VBA demonstration for a starting point
as you should be more accurate with directories like files names (v2) :
PHP Code:
Sub Demo1()
Const B = "D:\Users\PC-MKK\dektop\ MONTHLY FILES\", S = "C:\Users\PC-MKK\Downloads\", C = vbLf & vbLf
Dim IL, L
If Dir(B, 16) = "" Then Beep: Exit Sub
IL = [{"DATA_MONTLY","REPORTS RETURNS_MAR"," INVOICES ARCHIVE"}]
For L = 1 To UBound(IL)
If Dir(S & IL(L)) = IL(L) Then
If Dir(B & IL(L)) = IL(L) Then Kill B & IL(L)
Name S & IL(L) As B & IL(L)
IL(L) = False
End If
Next
IL = Filter(IL, False, False)
If UBound(IL) > -1 Then MsgBox "Not found in " & S & " : " & C & Application.Transpose(Join(IL, C)), , "Control"
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Last edited by Marc L; 04-17-2022 at 05:22 AM.
Reason: movie optimization !
Re: move specific files from directory to another without using cells
I create new file ,then the error is gone , but why tell me the files are not existed in this directory C:\Users\PC-MKK\Downloads\ despite of I use copy & paste to match the names into code with the files names to avoid sensitive spaces . do you have any idea?
Re: move specific files from directory to another without using cells
With normal attribute then the issue may come from specific characters like from other OS than Windows,
just try to rename the file(s), that's all I can guess without any further information …
Re: move specific files from directory to another without using cells
even if the directory is correct , it still shows message the files are not found in this C:\Users\PC-MKK\Downloads\:
DATA_MONTLY
REPORTS RETURNS_MAR
INVOICES ARCHIVE
I attach the file & picture for my files names in folder, may be you find out the problem like office-version or else thing
Re: move specific files from directory to another without using cells
Yes 'cause those files do not exist ! As I warned in post #8 you forgot the extension like file.pdf or file.xlsx
so just check obviously the complete filenames then update the VBA procedure accordingly …
Bookmarks