Results 1 to 2 of 2

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    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.

    Regards,

    Ash-Makda.


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgwviLabd7r_3KpP6wh4AaABAg. 9h5lFRmix1R9h78GftO_iE
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgyG714V_k7odQMrTz14AaABAg. 9h740K6COOA9h77HSGDH4A
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgyG714V_k7odQMrTz14AaABAg. 9h740K6COOA9h76fafzcEJ
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgyG714V_k7odQMrTz14AaABAg. 9h740K6COOA9h759YIjlaG
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgyG714V_k7odQMrTz14AaABAg. 9h740K6COOA9h74pjGcbEq
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgyG714V_k7odQMrTz14AaABAg
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgzJJUDVv2Mb6YGkPYh4AaABAg. 9h5uPRbWIZl9h7165DZdjg
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=316705#p316705
    https://eileenslounge.com/viewtopic.php?p=316704#p316704
    https://eileenslounge.com/viewtopic.php?f=27&t=40919&p=316597#p316597
    https://eileenslounge.com/viewtopic.php?p=316412#p316412
    https://eileenslounge.com/viewtopic.php?p=316254#p316254
    https://eileenslounge.com/viewtopic.php?p=316280#p316280
    https://eileenslounge.com/viewtopic.php?p=315915#p315915
    https://eileenslounge.com/viewtopic.php?p=315512#p315512
    https://eileenslounge.com/viewtopic.php?p=315744#p315744
    https://www.eileenslounge.com/viewtopic.php?p=315512#p315512
    https://eileenslounge.com/viewtopic.php?p=315680#p315680
    https://eileenslounge.com/viewtopic.php?p=315743#p315743
    https://www.eileenslounge.com/viewtopic.php?p=315326#p315326
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40752
    https://eileenslounge.com/viewtopic.php?p=314950#p314950
    https://www.eileenslounge.com/viewtopic.php?p=314940#p314940
    https://www.eileenslounge.com/viewtopic.php?p=314926#p314926
    https://www.eileenslounge.com/viewtopic.php?p=314920#p314920
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 04-24-2024 at 07:27 PM.

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    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

    Code:
    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
        Loop
        
        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 doug@powerstroke.us in forum Excel Help
    Replies: 2
    Last Post: 05-22-2013, 06:45 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, 11:37 AM
  3. Replies: 0
    Last Post: 09-06-2011, 01:31 AM
  4. Find Parent Folder From Given Folder / File Path
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 1
    Last Post: 05-28-2011, 03:50 PM
  5. Replies: 0
    Last Post: 04-03-2011, 07:57 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
  •