+ Reply to Thread
Results 1 to 7 of 7

Copy and Paste data from .xlsm workbook to .xls workbook

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Copy and Paste data from .xlsm workbook to .xls workbook

    Good night everyone,

    I've been stuck on how to send information from my .xlsm workbook to a .xls workbook. I keep getting a debug error at

    Please Login or Register  to view this content.
    Here is what I currently have. The .xls workbook opens but a error comes up (run-time erro '1004') and the information isn't transfered. The .xlsm workbook is trying to send the information from worksheet "Data" to the .xls workbook fruits worksheet apples.

    Please Login or Register  to view this content.
    Anything would be great.

    Thanks!!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Copy and Paste data from .xlsm workbook to .xls workbook

    As far as I can see that code should work.

    What error messages are you getting and where are you getting them?

    Do you know if there's any code in the xls file that might be executed when you open it?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Copy and Paste data from .xlsm workbook to .xls workbook

    Hey Norie,

    There is no code in the .xls file. The error I am getting is "run-time erro '1004'" for line code

    Please Login or Register  to view this content.
    Do you know why this may be happening? Not sure if you want to give it a try to see what is happening.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Copy and Paste data from .xlsm workbook to .xls workbook

    I think I might know what the problem is.

    You are using Rows.Count with no workbook reference and you are dealing with workbooks with a different no of rows.

    So, if Rows.Count returns the no of columns in the xlsm file (1million and a bit) the code will error because the xls file only has 65535.

    Try this.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Copy and Paste data from .xlsm workbook to .xls workbook

    You just made me so happy! lol. It worked amazing, thank you so much Norie.

    I have one more question relating to this post. If I wanted to add a password to the .xls file, how and where would I write the code in what you provided above to unlock to worksheet and than lock it back before it saved the file?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Copy and Paste data from .xlsm workbook to .xls workbook

    You could put it inside the With End With, unlocking just before you copy and then locking after you've copied.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Copy and Paste data from .xlsm workbook to .xls workbook

    Wonderful. Thanks again...no wonder you are a Guru

+ 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