+ Reply to Thread
Results 1 to 7 of 7

Problem copying cells contents from one worksheet to another.

  1. #1
    Registered User
    Join Date
    03-11-2022
    Location
    Peterborough, England
    MS-Off Ver
    2016
    Posts
    3

    Problem copying cells contents from one worksheet to another.

    Can anyone help me with an excel vba userform issue im having?

    I’m trying to copy and paste data in a cell from one worksheet to another, but when I try to paste the data into the second worksheet, it pastes it into the same cell, but on the first worksheet??

    Im launching a userform via a macro on the first worksheet, called “Risk Assessment”. This switches over to the second worksheet, called “Hazard Selector”, and loads my userform.

    Heres the code for that macro, assigned to a button in the “risk assessment” worksheet.

    Please Login or Register  to view this content.
    I then use the form to make some selections in the “Hazard Selector” sheet, which put data into cell D11 on the “Hazard Selector” sheet.

    Using a button on the userform I then want to copy this D11 data, switch back to the “Risk Assessment” worksheet and close the userform. Im using this code to do this, assigned to a button on the Userform.

    Please Login or Register  to view this content.
    This seems to work, and I have the contents of cell D11 on my clipboard, however, when I now try and paste this data into my “Risk Assessment” worksheet, for example into cell A1- nothing happens.

    Instead, the contents paste into the “Hazard Selector” worksheet instead, into cell A1?!

    I cant for the life of me figure out why, can anyone help?!

    Many thanks

    Mod Edit: You are required to use code tags around your code - I have added them for you. I have also removed all the extraneous line returns in this post to make it legible.
    Last edited by AliGW; 03-11-2022 at 06:21 AM. Reason: Code tags added & redacted for legibility.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, Suffolk (England), but grew up in Sawley, Derbyshire
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2211 (Windows 11 22H2 64-bit)
    Posts
    65,357

    Re: Problem copying cells contents from one worksheet to another.

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. As you are new here, I will do it for you this time: https://forum.ozgrid.com/forum/index...et-to-another/)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" to anyone who has offered you help in your thread. You can reward them by clicking on * Add Reputation below theur user name on the left, if you wish.


    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,054

    Re: Problem copying cells contents from one worksheet to another.

    Try:
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    03-11-2022
    Location
    Peterborough, England
    MS-Off Ver
    2016
    Posts
    3

    Re: Problem copying cells contents from one worksheet to another.

    Thanks,

    This works in pasting the content to "risk assessment" range A1, however I want to leave the data on the clipboard so i can paste it into a cell of my choosing.

    What I have noticed, is that if I click into a different cell, then right click and paste to the cell I want the data in, it works.

    However, I need to be able to paste the data from a single right click, not click away to activate the "risk assessment" sheet.

    Thanks

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,054

    Re: Problem copying cells contents from one worksheet to another.

    I suspect that, when you copy the cell, you see the "dancing ants" around it. When you click on another cell, they are still there and hence you can right click and paste the data. However, I imagine that some action or event is cancelling the selection … the dancing ants are no longer dancing … and the data is no longer available to paste.

    You could, maybe, copy the cell to a variable, do whatever action is clearing the clipboard, and then copy the variable to the clipboard.

    Please Login or Register  to view this content.
    Courtesy: https://stackoverflow.com/questions/...vba-excel-2013

  6. #6
    Registered User
    Join Date
    03-11-2022
    Location
    Peterborough, England
    MS-Off Ver
    2016
    Posts
    3

    Re: Problem copying cells contents from one worksheet to another.

    Thanks TMS,

    You are right about the dancing ants, but I still get the same issue when switching back to the "Risk Assessment" page.
    One thing I have noticed is that if I run userform directly from within the VBA editor using the "play" button, it all works fine.
    However, launching my userform from a button on my first page doesnt allow me to paste the data correctly?

    I appreciate the help - thanks

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,054

    Re: Problem copying cells contents from one worksheet to another.

    However, launching my userform from a button on my first page doesnt allow me to paste the data correctly?
    I guess. I have nothing to help me diagnose the problem or offer a solution.

+ 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. Copying contents of an activesheet to another worksheet
    By raunaq in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2013, 03:50 PM
  2. Replies: 7
    Last Post: 06-11-2012, 07:41 AM
  3. Dropdown menu and Autofill
    By neilq5 in forum Excel General
    Replies: 1
    Last Post: 06-11-2012, 06:24 AM
  4. [SOLVED] Copying contents of a specified cell from 1 worksheet to another
    By mathew086 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2012, 12:58 PM
  5. Copying contents of a cell from another worksheet
    By Barking_Mad in forum Excel General
    Replies: 2
    Last Post: 11-17-2009, 10:26 AM
  6. Problem copying array values to worksheet cells
    By CoolGal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2008, 02:00 AM
  7. Problem copying cell contents
    By QJ in forum Excel General
    Replies: 3
    Last Post: 09-19-2005, 10:05 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