+ Reply to Thread
Results 1 to 5 of 5

VBA code to open all files in a directory and move data to destination sheet

  1. #1
    Registered User
    Join Date
    02-06-2017
    Location
    California, US
    MS-Off Ver
    Office 2016
    Posts
    38

    VBA code to open all files in a directory and move data to destination sheet

    Hello,

    I am having trouble with a macro I am attempting to create.

    I would like to use this macro to perform a few steps (listed below) to automate a task.

    Step 1: I need to open all or one file in a specific directory and create a new sheet in the workbook for that file/s. (I believe I have a good handle on this step so far but any advice is welcomed)

    Step 2: These file/s in this specific directory will always have the data I need in a specific cell in the sheet. I would like to move the data from the file I am opening to the "destination Sheet" and dump it in the correct column.

    I cannot wrap my head around the correct code to move data that is in a cell that has yet to be created which is where I find myself. I have attached an example, any advice is welcomed

    Code for step 1
    Please Login or Register  to view this content.
    Thank you,
    Anthony
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA code to open all files in a directory and move data to destination sheet

    Is it possible that you are closing the workbook, to soon? Possibly close the workbook after you paste.

  3. #3
    Registered User
    Join Date
    02-06-2017
    Location
    California, US
    MS-Off Ver
    Office 2016
    Posts
    38

    Re: VBA code to open all files in a directory and move data to destination sheet

    Davesexcel,

    Step 1 is actually working it is just step 2 which I am having an issue with.

    "Step 2: These file/s in this specific directory will always have the data I need in a specific cell in the sheet. I would like to move the data from the file I am opening to the "destination Sheet" and dump it in the correct column.
    "

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: VBA code to open all files in a directory and move data to destination sheet

    Oh, so you don't have that in the code right now?

    What would the step be and what determines the correct column

  5. #5
    Registered User
    Join Date
    02-06-2017
    Location
    California, US
    MS-Off Ver
    Office 2016
    Posts
    38

    Re: VBA code to open all files in a directory and move data to destination sheet

    No, the code above accomplishes step 1 (import one or more files from a specific folder and paste them in their own sheet).

    Basically I want to just learn the process so I can do the fine tuning and exact references myself. For learning purposes I would like column a values in the "OpenedFile" sheet to fill in the column A within the form on the "DestinationSheet"

+ 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] VBA code to open all files in a directory and move data to destination sheet
    By anthony777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2017, 04:10 PM
  2. [SOLVED] Code to open Files in a Directory and change formula
    By coach.32 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-16-2015, 02:07 AM
  3. Replies: 1
    Last Post: 04-19-2012, 07:59 PM
  4. Excel Macro Code Request for List files and Move specified directory
    By ganeshinscribe in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-19-2012, 08:38 AM
  5. Move files from one directory to another based on excel data
    By CWinkler in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-28-2011, 10:05 PM
  6. Replies: 1
    Last Post: 04-28-2011, 05:02 PM
  7. Problem with code - move files to another directory
    By uncleslinky in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-14-2011, 10:06 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