+ Reply to Thread
Results 1 to 18 of 18

Strange behavior when using copy paste in VBA

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Strange behavior when using copy paste in VBA

    Newbie here, glad I found the forum and hope someone can help with the very strange problem.

    Background

    Last summer, I got a new PC with Office 2010 already installed. Throughout the years, I have done a lot of VBA programming but I have never seen this issue. On to the problem.

    I have created several VBA programs which analyze other spreadsheets and when I detect a record in the spreadsheet that I want to save, I copy that line in the scanned spreadsheet into a new spreadsheet. All of the macros are different but seem to have the same issue.

    During some of the row copy and pastes, a windows explorer window automatically opens to my windows SkyDrive folder (I have the desktop version of SkyDrive installed). It is a completely random event and even if I run the application again, it doesn't occur at the same location. I have attempted to re-write the copy paste command in several different forms but nothing has prevented this from happening. I believe it is a bug somewhere in Excel VBA and/or SkyDrive (no other folder opens automatically). BTW, there are no references to the SkyDrive folder in anything I am coping.

    Anyway, just curious if anyone else has experienced this very strange behavior. Thanks

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Strange behavior when using copy paste in VBA

    I use 2003 but it has a quirk depending on whether the calculation setting is automatic or manual - you might try toggling your calculation setting to see if that's the reason!
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    Thanks for the suggestion but I had already tried that one. I also tried to disable alerts and few other things. The problem is still there.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Strange behavior when using copy paste in VBA

    I have never heard of such a problem unless you are copying formulas that refer to non-existent locations
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    There are only strings and numbers in the cells that I am copying. They are going from one page of same workbook to another page. I believe it to be an interaction with Windows SkyDrive. Not sure why though.

    I have also tried using the clipboard copy and it does the same thing. The code copies several hundred rows which may have something to do with it because it doesn't exhibit this problem unless there are a lot of rows to copy.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Strange behavior when using copy paste in VBA

    Hi markinpt,

    Maybe it's the clipboard - you could assign your input records to a variant and then - assign the variant to the output range - it would be faster than the clipboard and might evade the conflict!

  7. #7
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    Actually, the current version is not using the clipboard. I tried it both ways. I do a direct copy via:

    row1.Cells.Copy Destination:=dWS.Cells(dRow, 1)

    According to the Excel VBA documentation, that method does not use the clipboard. Plus I also need the formatting and I really didn't want to transfer the format for each cell individually although that might fix the problem. I can live with the windows popping up but I was curious why it was doing that.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Strange behavior when using copy paste in VBA

    I suppose that this wouldn't fix it either????

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    Aren't they the same call? I thought the keyword "Destination" was optional. I will try it without the keyword and see if it makes a difference.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Strange behavior when using copy paste in VBA

    yes they are the same call

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Strange behavior when using copy paste in VBA

    I'm just reaching at straws - you never know what doesn't work the way it should!

  12. #12
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    Same Result

  13. #13
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    UPDATE -- 3 years later, I am now on Windows 10, Office 2016. a new PC, SkyDrive is now OneDrive and I am still getting the same problem when copying and pasting. I only do this when debugging so it isn't a huge problem but it is just the weirdest thing. It only happens for a couple of the copy and pastes (6-10 out of 1000s).

    Just wondering if after all this time, anyone else has seen this.

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Strange behavior when using copy paste in VBA

    I just wonder whether any of us could replicate that - could you post something for us to try?

  15. #15
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    I will see if I can create a stripped down version that exhibits the same behavior and is repeatable.

  16. #16
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    Ok, I have a really stripped down version that seems to cause the issue fairly repeatably. But only the first time it is run after opening the workbook. After that, it no longer opens up OneDrive folders.

    It doesn't seem to matter if the workbook is on onedrive or not but of course you have to have onedrive running.

    https://www.dropbox.com/s/kglfmowlnu...v001.xlsm?dl=1

    Looking forward to see if anyone else exhibits the same behavior.
    Last edited by markinpt; 09-26-2016 at 08:20 PM.

  17. #17
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Strange behavior when using copy paste in VBA

    Hello markinpt,

    I do not have OneDrive, but please try the attached sample, and see if that works for you.
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  18. #18
    Registered User
    Join Date
    01-30-2013
    Location
    Pleasanton, CA
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Strange behavior when using copy paste in VBA

    This is a single copy and paste of the entire tab which will not work for my needs but thanks anyway. I have simplified the actual macro quite a bit but the original picks and chooses which rows to copy out of hundreds of tabs. It doesn't actually copy an entire tab.
    Last edited by markinpt; 10-07-2016 at 10:34 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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