+ Reply to Thread
Results 1 to 9 of 9

Command button copy selection to another sheet

  1. #1
    Registered User
    Join Date
    10-08-2009
    Location
    Georgia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Exclamation Command button copy selection to another sheet

    I am relatively new to using Macros and cannot figure out how to code a command button to do the following:

    I have two sheets:

    Sheet1 has the following cells that need the following data entered:
    A1 to enter Name
    A2 to enter Job Title
    A3 to enter Department

    Sheet 2 is a list of choices:
    Names in Column A
    Jobs Title in Column B
    Departments in Column C

    I have a command button on sheet 2 that should do the following:
    when I select any name on sheet2 and click the command button, it will copy that name, cooresponding Job title, and Department for that person into the appropriate cells on sheet 1 (A1, A2, and A3)

    This is a little too complicated for me to figure out on my own and any help is very much appreciated!!
    Last edited by hlester; 10-09-2009 at 09:12 AM. Reason: Post Title

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: copy data to different sheet

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: copy data to different sheet

    I have edited your Thread tile this time.

    Take a look at the Contacts form example here

    http://excel-it.com/vba_examples.htm

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Macro Help with Command Button Needed!

    Hello hlester,

    Welcome to the Forum!

    Here is the code to add to your button.
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    Add the Macro to the Command Button
    1. Right Click the Button.
    2. Click View Code...
    3. A new window will open in the Visual Basic Editor like below
    Please Login or Register  to view this content.
    4. Type in the macro's name. You code you should like this...
    Please Login or Register  to view this content.
    5. Press Ctrl+S to save the changes.
    6. Press Alt+Q to return to Excel.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    10-08-2009
    Location
    Georgia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Command button to copy data to different sheet

    Thank you for the quick reply, but I am getting a Run-Time error '438' Object does not support this property or method. Also, when I right click the command button I do not have an option for 'view code'. I have an "assign macro" option though.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Command button to copy data to different sheet

    You are using a forms Commandbutton not an ActiveX from the Controls Toolbox.

    Do you have a Sheet1?

  7. #7
    Registered User
    Join Date
    10-08-2009
    Location
    Georgia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Command button to copy data to different sheet

    You are right thanks.

    I changed it and I still get that same error.

  8. #8
    Registered User
    Join Date
    10-08-2009
    Location
    Georgia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Command button copy selection to another sheet

    Please Help, If I need to upload a sample spreadsheet I can do so. I do have sheet1 and sheet2 and I used the activeX Command Button from the toolbox. Sheet 2 has the information on it which needs to be transfered to sheet 1 when selected and the button is clicked...

    I am still getting the Run-Time Error 438: Object does not support this property or method

    Thanks a bunch!

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Command button copy selection to another sheet

    Hello hlester,

    If you upload your workbook in Excel 2003 format, I can take a look at it and correct the problem for you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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