+ Reply to Thread
Results 1 to 18 of 18

Error in Copy Paste Code

  1. #1
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Error in Copy Paste Code

    Hello excel friends....

    I found this code from Internet for Copy and paste workbook data but i am unable to modify it in my own condition

    1. code is working flawless but below code is good for only one sheet but when i want to copy the data from more than one workbook it failed becoz every workbooks have Col A:A is blank and ROW A1 to XFD1 is blank
    please anyone modify this code

    Please see the attached file for better understand the condition

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by AVG123; 05-17-2020 at 10:45 AM. Reason: forgot the sample file

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    Using the macro here on my own workbooks (I did not download the files you posted) ... the macro seems to work fine.
    I changed one line of code so the macro downloads from the ACTIVESHEET instead of a specifically named sheet.

    See if that works for you.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    please try to download these file and then run the code for better understand
    Attached Files Attached Files

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Error in Copy Paste Code

    Try changing this line from:
    wkbDest.Sheets("Sheet1").Cells(wkbDest.Sheets("Sheet1").Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
    to
    wkbDest.Sheets("Sheet1").Cells(wkbDest.Sheets("Sheet1").Rows.Count, "B").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    Ok

    I downloaded both workbooks.

    I put your macro into a Third new workbook and ran it by opening both workbooks (one at a time) and downloading the existing data onto Sheet1 of my new workbook.

    Worked flawlessly.

    Is there something else you wanted the macro to do ?

  6. #6
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    It is not working when i select more than 1 workbook....please fix it

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    Are you attempting to select more than one workbook at a time ... instead of selecting one workbook, downloading the data ... then open a different workbook and repeating the process ?

    If that is what you are attempting to do, the macro is not designed for that.

  8. #8
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    Sir both sheets have 291 rows data but when i open both then it is showing only 274 rows data without heading

  9. #9
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    yes sir i am selecting more than one workbook at a time

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    When I run the macro here .... the large file downloads 289 rows of data without the headers. The smaller file downloads 15 rows of data without the headers for a total of 304 rows of data.

    I don't know the reason why it downloads less rows of data at your location.

    ???

  11. #11
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    Sir how is it possible
    1. First file have B2 to B277 data (including Header)
    2. Second file have B4 to B19 rows data (total 15 rows data should be paste after complete step1 without header)

    then total should be 292 rows data

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    See attached ...
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    Sir it is working but i want to work on more than one file in one time......not one after one

  14. #14
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    Let me look at it. I will need some time to construct the new macro.

    The new macro will require that ALL workbooks be in the same folder.

  15. #15
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    Right sir please take time to fix it......i will waiting for that

  16. #16
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    Please Login or Register  to view this content.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    320

    Re: Error in Copy Paste Code

    Thanks sir it is working fine but few amendment i want........
    1. Cant choose the specific file (ask me to choose the file)
    2. Copy and paste is working fine but after first file code insert 09 blank rows and next file's Heading also....... i just want paste the data continuously without heading.....becoz heading already exist on top of the file

    Thats it

  18. #18
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Error in Copy Paste Code

    .
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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] Copy and Paste VBA code error
    By gan_xl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-21-2016, 08:44 AM
  2. VBA Code Error when I copy and paste from another workbook
    By madison121 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2015, 05:31 PM
  3. Copy paste value - Macro code error
    By Dial1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2014, 05:27 PM
  4. Macro Code Copy Paste Error
    By FLani in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-21-2013, 10:54 PM
  5. Copy paste code error
    By shaukat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2011, 05:12 PM
  6. Error on code to copy and paste user selection.
    By leaning in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2011, 10:52 AM
  7. Compile error in copy/paste code
    By carbonboywonder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2010, 07:46 AM

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