Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

move files from one folder to another

Tags:

excel

vba

actually I am searching for code to move excel files from one folder to another if there is any way to do so Please someone help me. I am very sorry but I dont know how to do coding as I have never used VBA in fact I see it for the first time.

I will be grateful to you

like image 693
Rahul Avatar asked Jul 19 '16 11:07

Rahul


2 Answers

Sub MoveFiles()
    Dim FSO As Object
    Dim SourceFileName As String, DestinFileName As String

    Set FSO = CreateObject("Scripting.Filesystemobject")
    SourceFileName = "C:\Users\Jun.xlsx"
    DestinFileName = "C:\Users\Desktop\Jun.xlsx"

    FSO.MoveFile Source:=SourceFileName, Destination:=DestinFileName

    MsgBox (SourceFileName + " Moved to " + DestinFileName)
End Sub
like image 186
Arun Banakar Avatar answered Sep 17 '22 13:09

Arun Banakar


Try with the below code

Sub test()
    Set fso = CreateObject("scripting.filesystemobject")
    fso.MoveFile Source:="C:\work\test1.xlsx", Destination:="c:\work\movecheck\" ' replace with source and destination as required.
End Sub
like image 40
Karthick Gunasekaran Avatar answered Sep 19 '22 13:09

Karthick Gunasekaran