+ Reply to Thread
Results 1 to 12 of 12

Copy from one workbook to another workbook.

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Copy from one workbook to another workbook.

    Please Login or Register  to view this content.
    I am using the code above to copy a range of cells from workbook wbSatai to workbook wbShori. It works fine but the problem is that from wbSatai the copied cells has lots of merged cells but when pasted to wbShori the cells are unmerged. Another thing is that one column in wbSatai is of percentage format. The original values are something like 69.12541254 but what you see on the workbook is 69.13% now the problem is that when I pasted it on wbShori the value becomes 69.13 with a little green arrow on the side. I know there is not much changed but the thing is that I will be using the pasted values to another worksheet on wbShori so to get the exact value is very important. How can I copy and paste the values to another sheet and make the format and values the same. I thought xlPasteAll should have done the work but its not working.

    The 2 workbooks has the same filename but is located on a different folder so I cant open them simultaneously and do the comparison. Any help would be greatly appreciated. What am I doing wrong.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy from one workbook to another workbook.

    Try this,
    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Copy from one workbook to another workbook.

    Hi dave.
    I think that should have work but the 2 workbooks have the same filename so I can't open them simultaneously it results to error.

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy from one workbook to another workbook.

    See if this works for you.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Copy from one workbook to another workbook.

    Still gives the same result. I'm stock with this one since yesterday. (TT_TT)

  6. #6
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy from one workbook to another workbook.

    Sorry about that, left the key part out.
    Try this,

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Copy from one workbook to another workbook.

    Gives a runtime error...1004
    on the line with mergearea.

  8. #8
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy from one workbook to another workbook.

    Can you post a sample workbook with sensitive data taken out, that line should not give an error I believe.

  9. #9
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Copy from one workbook to another workbook.

    on the wbSatai workbook I uploaded I need to copy
    the values on Range("H8:Y37")

    the copied range should be pasted to wbShori workbook
    and hopefully retain the values as well as the formats
    but then as you can see on the wbShori I uploaded
    the pasted values Range("H40:Y69") somehow didnt retain
    the format...whats even worse is on the third column
    where the values are on percentage(%) the values are rounded up (ex. 22.125463541%--->22.22%)

    I needed the exact value because I need to compare those
    values if it is equal to the values on Range("H8:Y37") of wbShori.

    wbSatai's filename and wbShori's filename is sometimes the same
    that is why I can't open them at the same time
    to do the comparison. That's why I made it
    copy from wbsatai --->paste to wbShori --> do the comparison

    Thank you very much dave.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Copy from one workbook to another workbook.

    Anybody who knows how to solve this?

  11. #11
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Copy from one workbook to another workbook.

    I also get error when I use
    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    but I don't get and error when I use this,
    Please Login or Register  to view this content.
    However, the pasted values are still wrong..It doesnt copy the exact values instead the rounded up values and
    there are still green triangles on the side which meant that it encounters error when pasted.

  12. #12
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Copy from one workbook to another workbook.

    Ok, this is the only way I see this working. The ".MergedArea" won't work in your case.

    You will have to set the variable "IntCol" after the point I commented out

    Please Login or Register  to view this content.
    Last edited by JapanDave; 09-04-2012 at 10:32 PM.

+ 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