+ Reply to Thread
Results 1 to 19 of 19

Copy List of Hyperlinked Files From Source to Target Folder

  1. #1
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Copy List of Hyperlinked Files From Source to Target Folder

    I have a list of file paths and names (i.e. "C:\Folder\example.tif") in a column. I'd like to write a macro that would copy the entire list of files from their current location (on a network server) to a specified folder on my desktop. I've tried using the filecopy code, and that works, but only for a single cell. When I try to enter the full range of cells, it doesn't work. Any ideas?

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    You'll have to loop through each row in that column and use the filecopy for each line.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    So there is no way to automate the process? I'd have to rewrite the code for every single row?

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    No looping is a method of automating different iterations. If you would like to post the code you have so far I could create an example.

  5. #5
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Ok, here is what I have so far....

    Sub CopyFile()
    Dim src As String, dst As String, fl As String
    'Source directory
    src = Range("Q6", "Q139")
    'Destination directory
    dst = Range("S6", "S139")
    'File name
    fl = Range("R6", "R139")
    On Error Resume Next
    FileCopy src & "\" & fl, dst & "\" & fl
    If Err.Number <> 0 Then
    MsgBox "Copy error: " & src & "\" & fl
    End If
    On Error GoTo 0
    End Sub

    Please note that that code isn't working. You'll see that I'm trying to reference rows 6 through 139, but that doesn't work. If I reference just one row, the code works. Thanks for your help.

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Does the destination directory ever change?

    On a side note, please use code tags when posting code. To use code tags highlight your code and press the # in the toolbar.

  7. #7
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Sorry about that. Here you go...

    Please Login or Register  to view this content.
    And no, the destination directory never changes. I want all files to go into the same folder on my desktop.

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Please Login or Register  to view this content.
    Untested.

  9. #9
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Thank you. Should I use your code to replace all of mine? Or do I add yours underneath my existing code? (sorry, I'm new to VBA.)

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    It will replace the code you have (I hope).

  11. #11
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    I get the error: "Sub or Function not defined" and then it highlights "Sub ugadawgs311()"

    Do I need to completely delete my existing module (with my old code)?

  12. #12
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    No, just replace the code in the module with the code I posted.

    Including
    Please Login or Register  to view this content.
    Last edited by Solus Rankin; 03-25-2014 at 01:47 PM.

  13. #13
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    I still get the same error and highlighting of "Sub ugadawgs311()"

  14. #14
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Did you delete everything shown here:
    Please Login or Register  to view this content.
    including Sub CopyFile?

  15. #15
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Yes. This is the only code showing now...

    Please Login or Register  to view this content.
    Sub CopyFile has been removed.

  16. #16
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Please Login or Register  to view this content.
    Sorry typo. msbox was supposed to be msgbox.

  17. #17
    Registered User
    Join Date
    03-25-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    You're a lifesaver! Thank you. That worked. I got an error message on 2 of the files, but the other 132 worked perfectly. Thanks again.

  18. #18
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Glad to help. And welcome to the forum!

    If you only got an error on two of the files I would say it had to do something with the filename or filepath in the cell.

    If you are happy with the solution please mark the thread as [SOLVED] using the thread tools at the top.

    And on any thread you can show appreciation to those who have helped you by clicking the * below their post.

  19. #19
    Registered User
    Join Date
    04-01-2014
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Copy List of Hyperlinked Files From Source to Target Folder

    Hi,
    I have the same requirement with the variation that the destination folder changes.I have the source folder path Colum A,
    file names in Column B
    Destination path in Column C
    The source folder path Colum A,
    file names in Column B
    Destination path in Column C

    Each file which are there in Column B has to be moved to folders which are there in Column C entere for each of these files.

    Source File Names Destinations
    C:\Documents and Settings\Source Files Applle.xls C:\Documents and Settings\Destination Files/ Apple Folder
    C:\Documents and Settings\Source Files Ball.xls C:\Documents and Settings\Destination Files/ Ball Folder
    C:\Documents and Settings\Source Files Aple.doc C:\Documents and Settings\Destination Files/ Apple Folder
    C:\Documents and Settings\working Files aret.xls C:\Documents and Settings\Destination Files/ Apple Folder
    C:\Documents and Settings\Source Files Baby.xls C:\Documents and Settings\Destination Files/ Ball Folder



    Column A has the folder path where I have all my files.
    Column B has the file names from the above folder
    Column C has the destination where these files are to be moved.

    I have some 1000 files which are to be moved like this.

    I'll appreciate your help on this.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] open list of all .csv files in a folder and copy few colums in a excel of same sheet.
    By gnrao80 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-04-2014, 01:19 AM
  2. Macro To copy data of each month from source to target
    By jonhdoe1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2013, 08:02 AM
  3. copying data from excel files in a source folder to target folder
    By Javed07 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 04:27 PM
  4. [SOLVED] VBA Code open files in folder, copy text to workbook-Next time folder opened copy only new
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2013, 07:59 PM
  5. copy particular files to folder according to excel list
    By daxazz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-28-2012, 04:33 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1