+ Reply to Thread
Results 1 to 27 of 27

Copy ALL files from one folder to another folder

  1. #1
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Copy ALL files from one folder to another folder

    I need a VBA code that can do this

    I want this vba code to copy all files from one specific folder to another specific folder

    Thanks in advance

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    This is one method. The following will copy the folders and the files between folders.

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Copy ALL files from one folder to another folder

    No spaces in the foldernames.
    Please Login or Register  to view this content.
    Kind regards, Harry.

  4. #4
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    I dont want to delete the files from the source folder

    Also can we delete the part about date, I have no problem with the dates.

    Can we adjust the coding as such please?

    Thanks
    Last edited by misterno; 10-30-2022 at 01:17 PM.

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    At the very bottom of the FUNCTION code, eliminate these lines of code :

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Quote Originally Posted by Logit View Post
    At the very bottom of the FUNCTION code, eliminate these lines of code :

    Please Login or Register  to view this content.
    Thanks

    it works
    Last edited by misterno; 10-30-2022 at 01:28 PM.

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    You are welcome.

  8. #8
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    never mind
    Last edited by misterno; 10-30-2022 at 02:28 PM.

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    Well ... according to your last posted example of code, you've implement the SUBS and the FUNCTION twice. Its like you pasted the code twice.

    Did you mean to do that ?

  10. #10
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Quote Originally Posted by Logit View Post
    Well ... according to your last posted example of code, you've implement the SUBS and the FUNCTION twice. Its like you pasted the code twice.

    Did you mean to do that ?
    I have pinpointed the problem

    It only copies excel files but it does not copy csv files

    BTW, I doubled the code sorry about that. Code works perfectly for excel but not csv files

    Can you please fix that?

    Thanks
    Last edited by misterno; 10-30-2022 at 02:17 PM.

  11. #11
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    I tested the code here and cannot duplicate the error (.txt files) that you are seeing there.

    The code is designed to copy all files without regard of the type.

    ???

  12. #12
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Quote Originally Posted by Logit View Post
    I tested the code here and cannot duplicate the error (.txt files) that you are seeing there.

    The code is designed to copy all files without regard of the type.

    ???
    I tried 2 files one excel one csv and it is copying the excel file but not the csv file

    I can copy it manually with no problem but your code is not copying it for some reason

  13. #13
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    I just tried again with a different CSV file size 126kb and it worked

    But the CSV file I am trying to copy is 9K kb, is that the reason why it is not copying?

    This big file has 43K lines-rows of data
    Last edited by misterno; 10-30-2022 at 02:36 PM.

  14. #14
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Logit

    Would you please try your code with a large CSV file please?

    And let me know

    Thanks

  15. #15
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    Post the .CSV file you have that refuses to be copied. I'll use it and try to understand what is occurring.

  16. #16
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Quote Originally Posted by Logit View Post
    Post the .CSV file you have that refuses to be copied. I'll use it and try to understand what is occurring.
    I tried to attach it but it failed

    The max csv file size allowed as attachment is 1000kb

    Is there another way to send it to you?

  17. #17
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    Try again but this time delete a good portion of the data in the file. Just need maybe 200 rows of sample data.

    I forget what the max limit size is for files here.

  18. #18
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,242

    Re: Copy ALL files from one folder to another folder

    Why not just copy the folder and rename?
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  19. #19
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    He is having issues with only the single file. I suspect there is some type corruption affecting the copy process.

    ???

  20. #20
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Nmbbnnnnn

    Jhgbbbb
    Last edited by misterno; 10-31-2022 at 12:20 AM.

  21. #21
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Quote Originally Posted by Logit View Post
    Try again but this time delete a good portion of the data in the file. Just need maybe 200 rows of sample data.

    I forget what the max limit size is for files here.
    I will pm you
    Last edited by misterno; 10-31-2022 at 12:22 AM.

  22. #22
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    By chance, is the file format CSV for MacIntosh and not Windows ?

  23. #23
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Quote Originally Posted by Logit View Post
    By chance, is the file format CSV for MacIntosh and not Windows ?
    windows 10 I am using

  24. #24
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,242

    Re: Copy ALL files from one folder to another folder

    Ideally...Copy Folder contents at once to other Folder...
    Change red snippets to your paths
    Please Login or Register  to view this content.
    Or if you want to copy one at a time then...
    Please Login or Register  to view this content.
    Last edited by sintek; 10-31-2022 at 01:51 AM.

  25. #25
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Copy ALL files from one folder to another folder

    Sintek ... thanks for providing misterno a solution.

  26. #26
    Registered User
    Join Date
    02-09-2013
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    84

    Re: Copy ALL files from one folder to another folder

    Quote Originally Posted by sintek View Post
    Ideally...Copy Folder contents at once to other Folder...
    Change red snippets to your paths
    Please Login or Register  to view this content.
    Or if you want to copy one at a time then...
    Please Login or Register  to view this content.
    Thanks it works even for the large file

  27. #27
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,242

    Re: Copy ALL files from one folder to another folder

    misterno...No need to quote entire post...just clutters the thread...
    Glad to have helped...Tx for rep +
    Please remember to mark thread as SOLVED...

    Logit...Just giving back...What I was taught...Tx
    Last edited by sintek; 10-31-2022 at 02:09 PM.

+ 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. Copy files from one folder to another folder based on inputs from a table
    By kentnood in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-13-2022, 08:30 AM
  2. [SOLVED] Macro to copy .xlsm files in folder and sub-folder to foldr C:\old pull files
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2021, 09:55 PM
  3. [SOLVED] Copy Folder then rename files in new folder from list in Excel
    By jimjones1958 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2021, 05:00 PM
  4. VBA Copy specific files listed in Excel from folder & subfolders to another folder - FSO
    By HelloFriends in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2019, 02:55 PM
  5. Replies: 18
    Last Post: 02-18-2019, 07:42 AM
  6. Replies: 12
    Last Post: 03-09-2015, 05:52 PM
  7. [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

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