+ Reply to Thread
Results 1 to 14 of 14

transfer all xlsx to directory using VBA

  1. #1
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    transfer all xlsx to directory using VBA

    I am trying to transfer all .xlsx files from a temp directory to another folder using the below VBA, but currently the destination directory (varDest) is empty. varDest contains the full path to the folder and when I step-through the code it does have the correct value in it, but the files do not transfer. The .xlsx files can be removed from the temp directory once they are transfered. Thank you .

    VBA
    Please Login or Register  to view this content.
    Last edited by cmccabe; 01-16-2016 at 12:07 PM. Reason: added details

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: transfer all xlsx to directory using VBA

    Maybe change these 3 lines of code:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: transfer all xlsx to directory using VBA

    I made that change and when I step-through the vba I can see that the directory is there. However, the xlsx transfers to the sheet that the button is in. The attached screenshot shows this. Thanks you .
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: transfer all xlsx to directory using VBA

    Not sure what do with this information.

  5. #5
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: transfer all xlsx to directory using VBA

    When I run the vba it gets to the section where it moves the 4 xlsx files from the Temp folder (strFolderA) to the new directory (strFolderB). Only as of now I can see the files in the Temp directory but they get sent to the sheet the vba was executed from, not sent to the new directory. Does this help? Thank you .

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: transfer all xlsx to directory using VBA

    Not really. I don't see any code in your post that is capable of copying a worksheet into another worksheet. The only code I see creates a couple of path strings and then moves files between them.

  7. #7
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: transfer all xlsx to directory using VBA

    Weird, it is supposed to be copying the .xlsx files from the path strFolder A and transferring them to the path in strFolderB, but instead it is copying to the worksheet. The section of code before the transfer is included, does it look right? Thank you .

    VBA
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: transfer all xlsx to directory using VBA

    I am getting an invalid procedure call or argument

    Please Login or Register  to view this content.
    This may be part of the problem? Thank you .

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: transfer all xlsx to directory using VBA

    None of the code you've posted copies data from one excel file into another.

  10. #10
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: transfer all xlsx to directory using VBA

    Ok, so what is the best way to transfer all the xlsx files in
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    that is what I thought or am trying to do. Thank you .

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: transfer all xlsx to directory using VBA

    I've written code like you've shown virtually identical. I've highlighted the one thing I don't do, I'm assuming that some custom function.

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: transfer all xlsx to directory using VBA

    I will remove that and try again tomorrow (was supposed to be a timestamp on the files but I don't think its necessary). I will let you know tomorrow... thanks for all your help .

  13. #13
    Forum Contributor
    Join Date
    05-09-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2016
    Posts
    543

    Re: transfer all xlsx to directory using VBA

    So when I remove the two lines in red, I can see one of the 4 xlsx files transfer to the new directory but then I get an:
    Please Login or Register  to view this content.
    with the line in bold highlighted. When I step-though the code Name=Sheet (I don't think that is what I want)? Thank you .

    Please Login or Register  to view this content.

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: transfer all xlsx to directory using VBA

    Maybe change this:
    Please Login or Register  to view this content.

+ 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. convert all xlsx in directory to text using vb
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-28-2015, 09:52 PM
  2. [SOLVED] Save all xls files in directory as xlsx
    By StartRunMSPaint in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2014, 04:45 PM
  3. [SOLVED] convert xlsx to csv and save to file directory
    By shaz0503 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-27-2014, 07:19 PM
  4. Transfer file from one directory via vba
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2013, 07:09 PM
  5. Data Validation and macro enabled workbook
    By titantough in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2012, 12:55 AM
  6. Save all .xlsx files in a directory to .xls
    By paul00 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2012, 08:05 PM
  7. Writing to all xlsx files in a directory
    By BretFelix in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2010, 06:34 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