Consulting

Results 1 to 15 of 15

Thread: Using VBA to copy and paste the content of multiple worksheets to a new files

  1. #1

    Using VBA to copy and paste the content of multiple worksheets to a new files

    Firstly thanks for reading my thread.

    I am new to VBA and am trying to develop some code to copy data from a number of different files to one workbook.

    To explain, I am sent about 15 different files on a daily basis and need to copy the data from one of the worksheets in each of the files (on the second worksheet named ?compiled?) to one template named ?daily compiled?.

    The data copied from this worksheet will need to pasted to a specific worksheet in the new template file. For example Sarah will need to be copied to the ?sarah? worksheet and Tom will need to copied to ?Tom? work sheet.

    The range of the cells to be copied is D16:F57 and as I said previously this will need to be copied from file Sarah, Tome ect and been located on sheet name ?compiled? in D16:F57

    The files to be copied will be stored on my desktop in a folder name tracker details

    I hope that explains it well enough, I will be monitoring the post so if you have any questions please let me know.

    Thanks in advance
    Last edited by rugbyfitz; 07-17-2008 at 06:14 AM.

  2. #2
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    rugbyfitz,

    Tell me more about the target file: 'compiled'. Does it have one worksheet for each source file? Is there one 'complied' file per business day?

    Thanks,
    Ron
    Windermere, FL

  3. #3
    Quote Originally Posted by RonMcK
    rugbyfitz,

    Tell me more about the target file: 'compiled'. Does it have one worksheet for each source file? Is there one 'complied' file per business day?

    Thanks,
    Hi there

    cheers for your prompt responce.
    Ok so i recieved a number of daily files each of these has a number of worksheets. However its the 'compiled' worksheet that i want to be copied to a new file.

    Within the new file there will be seperate worksheets with a template ready to contain the copied data from all the daily files.


    at the moment i have to go through open each of the files sent to me, located the compiled worksheet, copy the selected range and past this into a new template in the approiate worksheet. Its this manual process that im hoping to remove.

  4. #4
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    rugbyfitz,

    Summarizing: you receive 15 workbooks each day, copy the selected range from the 'compiled' worksheet of each workbook and paste it to a separate worksheet in the new 'compiled' workbook. Tomorrow, youi'll receive another 15 workbooks and repeat the process.

    What are the names of the source workbooks? Is there a naming convention that you use for source and target workbooks? Do the target worksheet names already exist in the template workbook or should the process create them? Do you move the source workbooks into a specific folder for processing? Is the master copy of the target workbook kept in a particular folder? Do you want the new 'compiled' workbook saved to a particular folder?

    Food for thought (and future modifications):
    What do you want to do about a missing source workbook? How often do the people reporting to you change? Might the number reporting increase?
    Ron
    Windermere, FL

  5. #5
    Hi Ron

    in terms of the process, yes that?s correct, its basically a way of reporting on what?s been achieved each day by the individuals submitting the reports.

    The names of the new workbooks at present are the individuals name eg Carlie followed by the date the report refers to. However this could potentially change if required as a degree of manual work is needed to save the files initially from my emails.

    The target worksheet names do already exist within the template and the cells copied need pasting to the following destination: D16:F57 within each of their relative names worksheets

    The source folders are moved into a specific folder for storing however i cant tell you the address as every time i try to submit the message it tells me i dont have enough posts although this the location is not particularly important.

    In terms of saving the new compiled workbook to a folder that sounds like a good idea but am not overly fussed on the location

    Food for thought

    Missing files: there will be missing files, due to staff absences, we have a very simple excel function running that indicates which are missing. This is satisfactory

    Yes there is potential for all the number and names of people to change although I feel I will have to deal with as a separate project

  6. #6
    would you like me to send you the files so you have a look yourself?

  7. #7
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    rugbyfitz,

    It would help as long as it doesn't compromise proprietary or confidential data. If those are problems, then, provide me with the names you use for your target file and the tabs in it (as compared to the source file names, which I understand are in the form: 'myname' + 'today's date'.xls).

    Thanks,
    Ron
    Windermere, FL

  8. #8
    would it be possible to have a personal email address as i dont want to publish the files online?

  9. #9
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Did you find the PM I sent you?
    Ron
    Windermere, FL

  10. #10
    sure did, just putting together the email now.
    cheer for your help with this
    regards
    Nick

  11. #11
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Ron & rugbyfitz, any chance of the solution being put online for all to see? I can understand the need to confidentiality in relation to work material, but others might well be interested in what solution you arrived at.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  12. #12
    VBAX Regular
    Joined
    Jun 2008
    Posts
    53
    Location
    I second that.

  13. #13
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    A utility for saving
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  14. #14
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Quote Originally Posted by Aussiebear
    Ron & rugbyfitz, any chance of the solution being put online for all to see? I can understand the need to confidentiality in relation to work material, but others might well be interested in what solution you arrived at.
    Aussiebear, et al,

    You haven't been missing anything. I'm finishing up the code this evening after getting some help from Malcolm, yesterday. I will post the solution here when it's done.

    Cheers!

    Ron
    Last edited by RonMcK; 07-21-2008 at 05:44 AM.
    Ron
    Windermere, FL

  15. #15
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Nick, Aussiebear, Kiyiya, et al,

    Attached is a copy of the completed program. Let me recap what the requirements were.

    Nick needed a program that would read the individual workers' daily time tracker worksheets and copy a range of data from each worksheet into that worker's worksheet in the supervisor's summary workbook containing one sheet for every worker. These sheets are linked to 3 summary pages used for analysis and reporting. In Nick's instance there are 2 supervisors.

    The daily summary file is built from a template (.xlt) file (one for each supervisor). These daily files' names include the date of the work. When the program encounters an existing summary file during the build process, the program prompts for overwrite permission. The program does not flag any missing worker files because one of the worksheets in the file already reports that information.

    Since Nick wants to learn VBA programming, I heavily commented the program for his edification.

    Please let me know if you have any questions.

    Cheers!
    Ron
    Windermere, FL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •