+ Reply to Thread
Results 1 to 13 of 13

Opening Workbooks in a folder

  1. #1
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Opening Workbooks in a folder

    Is there a way to use a for next loop to open a workbook that is in a folder, then save and close the workbook then open the next workbook in the folder and do the same routine till all the workbooks have been updated?

    Any Idea's

    Thank You, Mike
    Last edited by realniceguy5000; 12-03-2008 at 01:39 PM.

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    I found this code and modified it to do somewhat what I want. Here is the problem. when it copies the formula from the workbook that is open it uses "wbResults" in the formula. I want it to use the workbooks name in the formula so the formula works? Also I need to place something in the code that lets me pick the active cell so the script can keep running. Here what I have so far maybe someone can take a look and give some advice.

    Please Login or Register  to view this content.
    Thanks So Much for any help!!! , Mike

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Mike,

    Here is the code to insert the open workbook name into the formula...
    Please Login or Register  to view this content.
    Where will the ActiveCell start and what are the other cell addresses that will have their formulae updated? For example, they way the code is now if you start at "A1" it will change the formuala in "B1", "C1", "D1", "E1", and "F1". Where are you starting in ThisWorkbook?

    Sincerely,
    Leith Ross

  4. #4
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    Good Day Leith,

    What can I say I was so close this time. However Your Modification Worked Great. Here are some additonal things I need from the script if possible.

    I want the script to start at cell J4. However as you can see with my offsets I then need the script to move to the right one space. once it finishes the current row it moves down to the next row with offset (1,6) which that part is working. I also need the script to know when it finishes with cell p24. At that point the script will need to move to the next worksheet to the right. in this case it would be moving from the Jan sheet to the Feb sheet. and so on till it reaches the P24 Dec sheet.

    So sum up the script needs to start at J4 and end at p24 on everysheet Jan through Dec (wbThis).


    Any additional help would be great.

    Thanks Again Leith your work here is outstanding!!!! I could never thank you enough!!!!

    Mike

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Mike,

    In your code you have Offset(1, 6) which says you are going down 1 row and 6 columns across. If you start at J4 then the next cell would be P5. Did you mean to start at J4 and include cells K4:P4? Just want to be sure I understand this correctly.

    Sincerely,
    Leith Ross

  6. #6
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    Hi Leith,

    Let me explain better: The script will start on cell J4 on wbThis then goto K4 skip L4 Continue on with M4,N4,O4 and finish at p4 the next line moves the cursor down to J9 then wbResults closes and opens up the next sheet from the folder. at starts running through lines J9-P9 and so on. when it reaches cell P24 is when I want the code to stop and move to the next worksheet in wbThis at that point it will start again at J4 and so on.

    I hope that is a little bit more information. By the way the offset on the last line should be (offset(1, -6) Sorry

    Thanks So Much For your Help!!!

    Mike
    Last edited by realniceguy5000; 12-02-2008 at 12:34 PM.

  7. #7
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    I have also been working on this a bit trying to get somethings to work so here is what I have so far. However it runs just wont work like I want it to.

    Please Login or Register  to view this content.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Mike,

    I changed the macro based on what you have posted. Try it and let me know if I got it right.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  9. #9
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    Hi Leith,

    First off Thanks for your help.

    The script appears not to be working as well now. It looks as if it is not putting the formula's in the cells except the first range (J4:P4). However I think I understand why. and that is my fault because I didn't say that cell J4:J8 are merged cells meaning J4 is really cells (J4:J8) So really it looks like this:
    J4=(J4:J8) K4=(K4:K8) and so on. It didn't seem to be a problem till we changed the formula to cells. I will include a example workbook so you can see what I am speaking about. Also I didn't run the script long enough either to see if it switchs over to the next sheet.

    Key to examples:
    wbThis = Month Sheet
    wbResults= Week Sheet

    WbThis has 13 sheets the first sheet is a summery of all the next 12 sheets. I have only included the Jan sheet which is the 2nd sheet in line. the rest of the months follow this sheet.

    wbResults is the sheet I'm pulling the data from all 59 sheets are exactly the same and only pulling the data from c3:I6 then the script closes and opens the next sheet.


    Let me know if you need more information. And thanks again.

    Mike
    Attached Files Attached Files

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Mike,

    Sorry about the late question. Everything seems to happen at once. Do you want to transfer all the data from each of the monthly sheets in workbook to the "Large Area" workbook or do you want to something else? Just so I am clear on this, each row in the "Large Area" worksheet will have the formula linking it to the sheet in the "This Month" workbook, correct?

    Sincerely,
    Leith Ross

  11. #11
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    No Problem I have been working myself off and on all day.

    Lets see let me try to simplify this mess...lol

    there are 59 workbooks with one sheet each in the large area folder all I want is to open up each of those workbooks(wbresults) one at a time and take the information from row 3 col c,d,f,g,h,i Then paste the link to the (wbThis) Jan -Dec in the respective week slot

    wbThis has 13 worksheets in this order 2009 totals, Jan,Feb,March,April,May,June,July,Aug,Sept,Oct,Nov,Dec

    So basiclly I want the infomation from the week sheet on the monthly sheet.

    I think I confusing the issue myself.

    Let me know if you need additional info...

    Thank You, Mike

  12. #12
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    Good Morning,
    I have been working on this script and with the help of some small posts and research I have almost got this working. I think I am only missing one piece of the puzzle now.

    What I need now is to only check and see if there is a date in column(B) before going on with the calculation in the (J) Column.

    Any Idea's
    Thank You, Mike

    Here is the updated code
    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951
    Well I got it to work, Although it may not be a perfect script layout. It works... Many thanks to everyone for there input and special thanks to Leith Ross.

    Thanks Again!!!!

    Mike

    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