Results 1 to 2 of 2

Thread: Move File From One Folder To Another Folder Within Mapped Drive using VBA in Excel

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Rep Power

    Move File From One Folder To Another Folder Within Mapped Drive using VBA in Excel

    Hi Guys,

    I am trying to create a macro to move files from a directory to a subdirectory on a mapped drive, mapped as Z:. My folder is (z:\ash\Resumes)

    I have a list of resumes(close to 50,000) on an excel sheet and hyperlinked so I can open any I want from excel. Now I have received a list of Termed employees and I want to move their PDF files to a subfolder in that directory called "Termed" (Z:\ash\Resumes\Termed).

    hyperlink shows the path as File:///\\ABC-Strata\ash\Resumes\Olivia Robinson.pdf for one instance. Since I am a complete novice at networking or mapped drives, I can't devise a solution. Can anyone help?

    Thanks in Advance.



  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Rep Power
    Ash, welcome to ExcelFox community.

    First, how would the program know that for example Mr. ExcelFox is termed? Second, in your worksheet, are all the hyperlinks in the same column one below the other? Instead of the developers doing a guess work here, can you post a sample workbook so that the code could be written accordingly.

    For a more generic code, try this

    Sub MoveFiles()
        Dim strFolderA As String
        Dim strFolderB As String
        Dim strFile As String
        Dim Cnt As Long
        '//Change the path to the source folder, accordingly
        strFolderA = "C:\Path\FolderA\"
        '//Change the path to the destination folder, accordingly
        strFolderB = "C:\Path\FolderB\"
        If Right(strFolderA, 1) <> "\" Then strFolderA = strFolderA & "\"
        If Right(strFolderB, 1) <> "\" Then strFolderB = strFolderB & "\"
        '//To filter for .xlsx files, change "*.*" to "*.xlsx"
        strFile = Dir(strFolderA & "*.*")
        Do While Len(strFile) > 0
            If Date - Int(FileDateTime(strFolderA & strFile)) > 2 Then
                Cnt = Cnt + 1
                Name strFolderA & strFile As strFolderB & strFile
            End If
            strFile = Dir
        MsgBox Cnt & " file(s) have been transfered to " & strFolderB, vbInformation
    End Sub
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Split Workbook In To Sheets, Export To Folder and Move File
    By in forum Excel Help
    Replies: 2
    Last Post: 05-22-2013, 07:15 PM
  2. List File name in folder to excel with images
    By Ryan_Bernal in forum Excel Help
    Replies: 2
    Last Post: 01-15-2013, 12:07 PM
  3. Replies: 0
    Last Post: 09-06-2011, 02:01 AM
  4. Find Parent Folder From Given Folder / File Path
    By Excel Fox in forum Excel Tips and Tricks
    Replies: 1
    Last Post: 05-28-2011, 04:20 PM
  5. Replies: 0
    Last Post: 04-03-2011, 08:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts