+ Reply to Thread
Results 1 to 13 of 13

Problems with copy and paste working with a command button.

  1. #1
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Problems with copy and paste working with a command button.

    I recorded a macro to copy and paste to my history sheet and it works when I use the ctrl A function, but when I assigned the same code to the command button; it stops working and gives me an error.

    Why won’t the code work with the command button? I haven’t got to it yet, but I need the history page to keep dropping one row for the new data every time it copies and paste the information. This way it won’t overwrite data.

    When I return to sheet1, the selection I copied is still selected, is there a way to deselect this automatically so when I return to the page it isn’t selected?

    This is the code that was recorded.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jeffreybrown; 07-13-2013 at 10:34 AM. Reason: As per Forum Rule #3, please use code tags…Thanks.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problems with copy and paste working with a command button.

    I do not know which is the source sheet so I used active sheet. You can change this line

    Please Login or Register  to view this content.
    INTO

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

  3. #3
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Problems with copy and paste working with a command button.

    Alright, the code works the first time, but on the second, third, and fourth time the code is run, it does not carry the date in correct format.

    I am also having trouble assigning the code to the button. My button keeps referring back to the old code after I clear it out and insert the new one.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problems with copy and paste working with a command button.

    "It does not carry the date in correct format".
    Which one is the source sheet?
    The code copies .Range("A3:H3").
    Which one is next or what is next?
    Where is the button so I can attach it to the code once we got the correct code?

  5. #5
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Problems with copy and paste working with a command button.

    The source sheet for the data is sheet1. It copies the info to the history sheet. The button is in I3 and moving all the data from it's left. I was able to get the code into it. When I right clicked it, I just assigned the macro to it.

    Is there a way to deselect the copy highlight automatically after the code has been run?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problems with copy and paste working with a command button.

    Please Login or Register  to view this content.
    Last edited by AB33; 07-13-2013 at 01:46 PM.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problems with copy and paste working with a command button.

    If you want to copy all rows

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Problems with copy and paste working with a command button.

    It is working, but it still is showing a number value (41465) for the date in the second, third, fourth, etc. rows. On the first run, it puts the date correctly, though.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problems with copy and paste working with a command button.

    It is formatting issue.

    Us this line

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

  10. #10
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Problems with copy and paste working with a command button.

    Okay, it works perfectly except I only needed to copy row 3 when the button was pushed.

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problems with copy and paste working with a command button.

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Problems with copy and paste working with a command button.

    Thank you very much. I am just beginning to try and learn vba. I always pick it up quicker if I jump right in, but I'm struggling with even some of the basics. If you recommend anything for me to read on the web or a book to purchase, I'd be more than happy to. I have been watching quite a few you.tube videos, but most of them don't cover anything like an active inventory sheet of this manner.

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problems with copy and paste working with a command button.

    This link is a good start.
    http://www.excelforum.com/excel-prog...materials.html.
    I was in your shoes about a year or so ago. I bought some books, but did not make much progress. Watching you tube did help me lots. Different people have different ways of learning and not two individuals are alike.
    The best way to learn is by "Doing". "Practice", Practice, and Practice".
    You are in the right forum.

+ 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. Copy and Paste as Values using Command Button
    By macky1730 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-04-2013, 02:18 AM
  2. Command button to add rows, copy and paste formulas, and format.
    By seankuus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2013, 08:37 PM
  3. copy and paste data from one worksheet cell to another using command button
    By jasonruiz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-13-2011, 04:34 AM
  4. Command Button protection problems????
    By Chris Watson in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2006, 11:30 AM
  5. Command Button Problems Still
    By Mikeice in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2005, 09: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