Closed Thread
Results 1 to 13 of 13

Using a macro to copy from one workbook to another

  1. #1
    Registered User
    Join Date
    11-23-2008
    Location
    Australia
    Posts
    15

    Using a macro to copy from one workbook to another

    Hi

    I have a spreadsheet with multiple worksheets in a spreadsheet which has been distributed and filled out by others.

    I would to be able to:
    -open each returned spreadsheet (by browsing and selecting the file)
    -click a macro and have the macro select information from a range for each worksheet and have that information copied into the relevant worksheet in a master spreadsheet. I.e workbook1 to workbook1, workbook2 to workbook2
    -during the copying process the information should be filled in the next empty row in the master spreadsheet

    Thanks,
    Last edited by steve_c; 02-10-2009 at 12:43 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Using a macro to copy from one workbook to another

    That's not difficult but where is the data to copy & how is it arranged? A sample workbook would help.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    11-23-2008
    Location
    Australia
    Posts
    15

    Re: Using a macro to copy from one workbook to another

    Thanks.

    You can see from both sheet, they are identical except one has data. I want to be able to transfer the information in the entry data spreadsheet into the master sheet, by clicking a macro that would sit inside the master spreadsheet (allowing me browse for that spreadsheet).
    Attached Files Attached Files

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Using a macro to copy from one workbook to another

    Try this code, add it to a Standard module

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-23-2008
    Location
    Australia
    Posts
    15

    Re: Using a macro to copy from one workbook to another

    Wow this code is pretty cool.

    Does the copy happen between the exact sheet numbers rather than sheet names?

    Could you explain a little more about the code around the range to copy and the destination range.

    I.e what does cells(2,1) mean etc.

    Also
    - can you add a code to specific certain worksheets not to copy?
    - as I have named ranges, everytime I open the code, it ask me whether I would like to replace. I would simply be able to ignore and go with yes all the time

    Thanks,
    Last edited by steve_c; 02-13-2009 at 01:15 AM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Using a macro to copy from one workbook to another

    Cells(2,1) is A2, ie row 2 , column 1. This amendment will allow you to excllude specific sheets

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-23-2008
    Location
    Australia
    Posts
    15

    Re: Using a macro to copy from one workbook to another

    Thanks for the update, but I seem to be getting an error at the

    With ws part of the code
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-18-2009
    Location
    Pakistan
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Using a macro to copy from one workbook to another

    Dear all

    I have attached two sheets one is Biodata other is Master

    Scenario:
    In biodata sheet users shall fill in their information and mail to me. I will be having a folder which contains 100s of these biodata forms from many individuals.

    Now I want transfer all the data (from specific fields) from alll 100 biodataforms into one Master Datasheet to further analyse the data.

    The sheet Master has the macro which enables me to browse through the computer and give the path of the file (biodata) and it automatically copies the required fields to the Data sheet in Master file.

    But it has to be repeated again and again i.e file by file.

    I want a macro through which I can give the path of the folder which contains all the biodata forms only once and it will extract the information to the Master sheet.

    Please help

    Adnan
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-23-2008
    Location
    Australia
    Posts
    15

    Re: Using a macro to copy from one workbook to another

    Hi

    How would you make this component of the code dynamic? I.e I want to copy and cut each range which would be different for each workbook rather

    Cells(.Rows.Count, 3).End(xlUp))

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Using a macro to copy from one workbook to another

    It is already dynamic.
    Entia non sunt multiplicanda sine necessitate

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Using a macro to copy from one workbook to another

    Quote Originally Posted by steve_c View Post
    Hi

    How would you make this component of the code dynamic? I.e I want to copy and cut each range which would be different for each workbook rather

    Cells(.Rows.Count, 3).End(xlUp))
    You may b e able to use CurrentRegion or UsedRange

  12. #12
    Registered User
    Join Date
    08-03-2010
    Location
    Greece
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Using a macro to copy from one workbook to another

    Hi everyone!

    I want to transfer data from an .xls file to an .xlsx.To be more specific,I want to copy Cells from A2 till M2 of the .xls file and paste them into the other file...Unfortunately,I wrote down a Code but it didn't copy the cells from the .xls file...What can I do?????PLEASE,HELP

    Antonis Grigio

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Using a macro to copy from one workbook to another

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

Closed 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