Command Button that Copy Paste Values into a another sheet in the first empty row

  • Hi


    I am trying to make to sheets:


    The first I want is having some cells where I type in Name, Adresse, City and so on.
    After I have entered this I have createt a command button. When I click this I want the to:


    Copy the information from the cells
    Pate the information from the cells in to a new sheet.
    Have a MessageBox to say "Information have been submited" and then make the cells empty for new entries


    When I repeat the I want the next information I type to be pasted into the nex row in "data"sheet.



    Can anybody help wíth a code for the button?

  • Re: Command Button that Copy Paste Values into a another sheet in the first empty row


    Hi Kehlet


    Try the following. Attached is a file to show how it all works.


    Take care


    Smallman



    Code
    Option Explicit
    Sub Upload()
    Range("A5", Range("C" & Rows.Count).End(xlUp)).Copy Sheets(2).Range("A" & Rows.Count).End(xlUp)(2)
    Range("A5", Range("C" & Rows.Count).End(xlUp)).ClearContents
    End Sub
  • I'm trying to use this, but need to make some adjustments but am not able to figure it out. I'm not very advanced with VBA.

    Code
    This is the code you provided:
    Option Explicit
    Sub Upload()
    Range("A5", Range("C" & Rows.Count).End(xlUp)).Copy Sheets(2).Range("A" & Rows.Count).End(xlUp)(2)
    Range("A5", Range("C" & Rows.Count).End(xlUp)).ClearContents
    End Sub


    My questions are:
    1. How do I do this between two different workbooks, instead of sheets?
    2. I don't want to clear contents, I only want to add new content. How do I do that?
    3. I want to copy only specific cells in the row (for example, A1 to A1, B1 to B1, C1 to D1)


    I couldn't find a forum to post this question.


    Any help would be appreciated.


    Thank you

  • Welcome to the Forum


    Please start your own post. Posting in another member's Thread is known as hijacking and is not allowed here. By all means add a link to a Thread that may be related to your question.


    Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags


    Just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.


    You need to read the Forum Rules before posting again.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!