+ Reply to Thread
Results 1 to 6 of 6

Looping through all Workbooks in directory to retrieve rows of information

  1. #1
    Registered User
    Join Date
    06-03-2008
    Posts
    3

    Looping through all Workbooks in directory to retrieve rows of information

    I have many workbooks in a directory (c:\East\), and I need to copy the same range of cells (A99:BM99) from a specific sheet ("General") and paste them into a file (Master.xls).
    So the copied range from the first file in the directory will be pasted in row 2 of master, the copied range from the next file in the directory will be pasted into the next row (row 3), and so on.

    Any suggestions?

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    Try:

    Please Login or Register  to view this content.
    Depending on the values of the cells you wish to copy and paste, pastespecial may be more appropriate. In which case change
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    Last edited by fecurtis; 06-03-2008 at 01:50 PM.

  3. #3
    Registered User
    Join Date
    06-03-2008
    Posts
    3
    Hey Fecurtis,

    Thanks for the speedy reply, much appreciated.

    Nothing seems to happen

    Im wondering if it has to do with the destination?

    My destination file is c:\East\Master.xls

  4. #4
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    Is the macro written within the file "Master.xls"? Is this the file you wish to paste all the values to? If it is and Master.xls is in the same directory try:

    Please Login or Register  to view this content.
    Last edited by fecurtis; 06-03-2008 at 02:42 PM.

  5. #5
    Registered User
    Join Date
    06-03-2008
    Posts
    3
    Yes, it is written right in there, and that is the file that I would want to paste it into. It appears that there is some sort of activity for a split second when I run the macro, but nothing appears in the destination.

  6. #6
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    Sorry I haven't gotten back to you in a while. I've been trying to figure this out. I know why its not working but can't quite figure out the best way to resolve the issue. The problem is that since Master.xls is located in the same director, the macro will open that and as a result, the additions its made before the reopen event are not saved and you're left with nothing. A few ways around this are:
    1. Set Application.DisplayAlerts on True and click "No" when you are prompted to open the same file or not.
    2. Use the code below. Its not the most efficient way to run through this. I tried to figure out how to tell the Macro to not even open the excel file if its the same file as thisworkbook but couldn't figure out how to. Perhaps someone on here could:

    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)

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