+ Reply to Thread
Results 1 to 7 of 7

Copied code from one excel file to another excel file

  1. #1
    Registered User
    Join Date
    01-08-2019
    Location
    Charlotte
    MS-Off Ver
    2010
    Posts
    4

    Copied code from one excel file to another excel file

    Hi everybody,

    I tried to copy a code from one file to another. It works perfectly in the old file. If you click the button, you choose an excel file and the macro copies the whole excel file and copies the information from the chosen file in the sheet data. However, it doesn't work if I copy it to my new sheet. Can you help me? Here is the code:


    Please Login or Register  to view this content.
    Last edited by Dom90; 01-08-2019 at 02:18 PM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,057

    Re: Copied code from one excel file to another excel file

    Dom90,

    Welcome to the forum

    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    It is also not clear what you mean by "Doesn't work" What is/are the problem(s)?

    Note that your macro does rely on there being a sheet named "Payment Request" as well as a sheet named "Data"... are those present in your new copy?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    01-08-2019
    Location
    Charlotte
    MS-Off Ver
    2010
    Posts
    4

    Re: Copied code from one excel file to another excel file

    Hi Arkadi,

    thank you for your response. I edited the code. I apologize for not making it more clear than "it doesn't work". After clicking the button and choosing the file to open, the new file opens and the following error message pops up:Attachment 605191.

    I also have the sheet's Payment Request and Data in my new file: Attachment 605193

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,057

    Re: Copied code from one excel file to another excel file

    Can't open the attachment so I can't see the error...

    Maybe you could attach the workbook that is the non-working copy?

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    P.S. thanks for fixing your original post.

  5. #5
    Registered User
    Join Date
    01-08-2019
    Location
    Charlotte
    MS-Off Ver
    2010
    Posts
    4

    Re: Copied code from one excel file to another excel file

    Hi Arkadi,

    I uploaded 2 files the way you described: 1 is the file where I copied the code and push the button. FSA_90K is the document I choose when the macro requests a document.
    Attached Files Attached Files

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,057

    Re: Copied code from one excel file to another excel file

    Things often get a little messy when working with multiple workbooks and moving between them especially if the code does not specifically address the workbook when activating a sheet/range etc.

    That said the errors it is returning are strange at times, and I can't explain why it worked in the old book and not a copy, technically the code should work, but I definitely see the same problems that I suspect you had.

    However, with a few changes in code (I did not look to re-write it, just deal with your problems), I believe it will run properly:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-08-2019
    Location
    Charlotte
    MS-Off Ver
    2010
    Posts
    4

    Re: Copied code from one excel file to another excel file

    Thank you so much for your help! It worked

+ 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] How do I stop an Excel file from being copied
    By John Driscoll in forum Excel General
    Replies: 11
    Last Post: 02-06-2019, 05:08 PM
  2. vba code for opening excel file and insert a new column in exisiting excel file
    By saratu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2014, 02:55 PM
  3. Converting excel 2003 file ext macro file-save code to reflect excel 2007 exts
    By pmanoloff in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2013, 12:17 PM
  4. [SOLVED] protect excel file from being copied
    By martinpols in forum Excel General
    Replies: 2
    Last Post: 01-04-2013, 11:14 PM
  5. Protect excel file from being copied
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2010, 02:44 PM
  6. [SOLVED] How to Create a file in Excel that can't be copied or printed:read only file
    By enroh in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-18-2006, 10:40 AM
  7. [SOLVED] Excel file 4MB.Copied sheets to a new file.Now=64Kb-easier way?
    By Suza in forum Excel General
    Replies: 2
    Last Post: 03-27-2006, 10:20 AM

Tags for this Thread

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