+ Reply to Thread
Results 1 to 9 of 9

Moving worksheets from workbooks in one folder to workbooks in other folders of same name.

  1. #1
    Registered User
    Join Date
    05-27-2016
    Location
    Toronto, Canada
    MS-Off Ver
    Office 2010
    Posts
    5

    Moving worksheets from workbooks in one folder to workbooks in other folders of same name.

    Hi,

    I am new to Macros and I am having a lot of trouble with this. I have a folder with about 90 timesheets. Each timesheet has 12 worksheets in them. It goes by the month. April, May, June, All the way to the May again. So what happens is at the end of every month Managers approve these time sheets and then the next month they are submitted back again and so on. The problem is the approved time sheets are not returned to the submitting party due to which when they submit the next month time sheet, it doesn't reflect managers approvals on it from the previous month. However, in a centralized location we need to keep all approved 90 workbooks and each workbook must reflect the approved worksheets in it.


    Having said that, what I am really trying to do is

    A folder contains Workbook XYZ and it has April worksheet that is approved and I want to import/copy that particular worksheet in another workbook of same name ( XYZ) in a different folder and repeat that for the other 90 workbooks as well.

    So for now, I have one folder with all January worksheets approved and one folder having all February worksheets approved and I am trying to have a workbook which will have both of these approved work sheets. They both are in different folders but the workbooks have same names and all worksheets.

    Please kindly help me with a VBA for this. If you are using a similar macro or can help me with one for this cause I would deeply appreciate it.

    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    This requires that you set a reference to MS Scripting Runtime in your project. Copy one set of files, say, the January set, into a new folder named Master Timesheets - update the "C:\FolderPath" part of the code - and when prompted, enter, say, February :


    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    05-27-2016
    Location
    Toronto, Canada
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    Can you please see this.png

    Can you please see the attached image. I tried to do it for January. Please let me know what I am doing wrong.

    Thanks,
    Mohammad

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    You did not set the required reference to MS Scripting Runtime - under Tools / References ... scroll down until you find it, and check the box to include it.

  5. #5
    Registered User
    Join Date
    05-27-2016
    Location
    Toronto, Canada
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    Sorry, I am still getting an error. I selected MS Scripting Run time.

    Can you please see this.png



    Can you please see this 1.png

    Can you please let me know what I am doing wrong. Once again, thanks for all your effort.

    Thanks,

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    The code is written just for month names, not month and year. It needs to be a sheet name and, apparently, a valid name for a folder : check the value that the variable strFolder2 is given.

  7. #7
    Registered User
    Join Date
    05-27-2016
    Location
    Toronto, Canada
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    Sorry, I forgot to mention that Apr-2015 is the name of the worksheet.

    So in each workbook, that is how worksheets are labeled.

    starts from Apr-2015, May-2015,............................all the way to the last worksheet which is named as March-2016

    One folder is named as "C:\Users\fareedmo\Desktop\Master Timesheets: ( This is where I have 90 sheets and I am trying to get Apr-2015: which is the April sheet and I want it to come from "C:\Users\fareedmo\Desktop\January" ....


    Sorry, I thought I would give you more information and may help you understand better because I feel a little confused after your explanation.

    Thanks for baring with me..

  8. #8
    Registered User
    Join Date
    05-27-2016
    Location
    Toronto, Canada
    MS-Off Ver
    Office 2010
    Posts
    5

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    Does this mean, If I want to use this code all worksheets names have to be changed to just the month names?

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Moving worksheets from workbooks in one folder to workbooks in other folders of same n

    No need to change the sheet names - but the code does need to change. (I wrote it without knowing exactly what your folder structure actually is.) This assumes that the newest timesheets will always be in the folder "C:\Users\fareedmo\Desktop\January" - I thought you would have "C:\Users\fareedmo\Desktop\February" etc. too.

    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. [SOLVED] identifying and moving information between 2 workbooks and 3 worksheets.
    By Ms Nikki in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-03-2015, 10:00 AM
  2. [SOLVED] identifying and moving information between 2 workbooks and 3 worksheets.
    By Ms Nikki in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2015, 04:49 PM
  3. VBA Copy macro-enabled worksheets to all workbooks in folder
    By Kahmed2R in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2013, 09:59 AM
  4. Moving data from monthly workbooks into summary workbook in same folder
    By hyneso in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2013, 07:15 PM
  5. [SOLVED] Split worksheets in multiple workbooks in folder
    By Eric09 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 01:12 PM
  6. Replies: 6
    Last Post: 02-21-2006, 04:25 AM
  7. Moving workbooks between folders
    By Ozzie in forum Excel General
    Replies: 3
    Last Post: 01-25-2006, 05:30 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