+ Reply to Thread
Results 1 to 24 of 24

Copy from one workbook to another-command button

  1. #1
    Registered User
    Join Date
    01-01-2004
    Posts
    14

    Copy from one workbook to another-command button

    I have a workbook name Updates. It has a command button that has the following code attached to it.
    Please Login or Register  to view this content.
    There's more code but my problem lies in this part of the code.
    What I am trying to do is copy the range A1 to G 205 in the workbook named "Walkroutes".
    then paste it into the workbook named "Updates"

    When I try to run the code it fails with a Runtime Error 1004 Select Method of Range Class Failed.

    Can someone help me with the code to make it copy the cells in the workbook "Walkroutes" and paste them into the workbook "Updates" ?

    Thank you for reading this and any help you can offer.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Crosspost

    Please stick to the forum rules and link to crossposts.

    http://www.mrexcel.com/forum/showthread.php?t=356002

  3. #3
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    I'm sorry............how do I go about doing that?

  4. #4
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    Here you go,

    Please Login or Register  to view this content.
    Hope this helps, you just need to replace the code Sheet2 to the name of your second sheet.

  5. #5
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    That's not what I'm trying to do. If I understand your code that will copy from a sheet in the workbook to another sheet in the same workbook.
    What I want to do is copy cells from a sheet in "Workbook A" to cells in a sheet in "Workbook B"
    In other words What I am trying to do is copy the cells in range A1 to G 205 in the workbook named "Walkroutes".
    and then paste it into a different sheet in a different workbook named "Updates"

  6. #6
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    Please Login or Register  to view this content.
    Try that.

  7. #7
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    you need to make sure that the work book2 is closed if you want to perform an update again. otherwise you will get an error. do you want it to close the workbook2 after updating the information?

  8. #8
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    Quote Originally Posted by theSizz View Post
    That's not what I'm trying to do. If I understand your code that will copy from a sheet in the workbook to another sheet in the same workbook.
    What I want to do is copy cells from a sheet in "Workbook A" to cells in a sheet in "Workbook B"
    In other words What I am trying to do is copy the cells in range A1 to G 205 in the workbook named "Walkroutes".
    and then paste it into a different sheet in a different workbook named "Updates"
    Ok I fixed it up and made it a bit neater.

    and now you dont have to close the book2.

    Please Login or Register  to view this content.
    Let me know how it goes

  9. #9
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    Did this solve the problem?

  10. #10
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    Sorry.
    It still doesn't copy. Still get a runtime error 1004

  11. #11
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    The error is because the file does not exist. go to the file on your desktop right click and go to properties and where it says location.

    That all error 1004 means.

    if that dont work try moving all files to the c drive

    so save book 1 into "C:\book1.xls
    and book 2 into "C:\book2.xls"

    Then change the last line of code to reflect this.

    Then it should work.

  12. #12
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    If you could upload both books so I can program it to reflect where you have it saved.

  13. #13
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    ok
    I want to copy from walkroutelan.csv to copyofwalkrt444.xlsm
    the code is included.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    I'm not sure if the second file got attached here it is again in case you didn't get it.

  15. #15
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    The first file is not here walkroutelan.csv

  16. #16
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    here is the first file.

  17. #17
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23
    still not there

  18. #18
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    I'm having trouble attaching the file. It wouldn't attach because the .csv format is not supported, so here it is in the .xlsx format.
    Here it is again.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    here it is in .xlsx format
    Evidently the .csv format is not supported and it wouldn't upload.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    11-22-2008
    Location
    Brisbane, Australia
    MS-Off Ver
    2003
    Posts
    23

    Smile

    Ok so let me get this right.

    You want to copy all information from Walkroutelan.xlsx and paste it into walkrt444.xlsm?

    Like what are you trying to achieve, as the data looks the same.

    Is this part of a bigger project?

    is it in relation to an order sheet type thing?

    please explain what your actual goal is and please be as descriptive as possible.

    Zip up all the files that reference each other and list for me what each file is meant to do.

    ie. I want to copy all data from walkroutelan.xlsx from cells A1 to G400 and paste them into walkrt444.xlsm B3

    I need references.

    and if you could save the files as plain .xls files that would make it easier to program them.

    Thanks

  21. #21
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    The sizz,
    the least you can do is to provide a link to this thread on the other forum you posted the same question.
    You are having different people working on the same problem without knowing that others are working on it.
    Keep in mind they are all volunteers and may be investing time to answer you when someone else has already done so

  22. #22
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    it's getting to past midnight here.
    I'll have a fresh head and deal with it in the morning.
    I really appreciate the time you've spent. I'll post back in the morning.
    Thank you so much.

  23. #23
    Registered User
    Join Date
    01-01-2004
    Posts
    14
    Thanks to rbrhodes who provided the solutions listed below.
    Both procedures work and produce the desired results.

    Here's the simplistic way:


    VBA:

    Please Login or Register  to view this content.


    and here's a better way


    VBA:

    Please Login or Register  to view this content.
    I'd like to thank all who worked on this for their time and effort.
    Being new to the forums I didn't realize about the cross posting issues and implications. Please accept my sincere apology.
    Thanks to all.

  24. #24
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Being new to the forums I didn't realize about the cross posting issues and implications. Please accept my sincere apology.
    Thesizz, you have been a member of two forums for 4 years, posted 27 times on another forum and 13 times on this one. I wouldn't call that new.
    You also didn't take the time to post the link on the other forum, showing no respect for posters .
    This attitude is not acceptable, and therefore I will ban you.
    I hope that after this period, you will have understood how things work on forums.

+ 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