+ Reply to Thread
Results 1 to 12 of 12

Need to create a button that can copy cells, create a new sheet and then paste there

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72

    Need to create a button that can copy cells, create a new sheet and then paste there

    So I've got Sheet 1 with say

    ____A___B___C
    1___m___i___c
    2___r___o___s
    3___o___f___t

    I would like to create a button that can create a new sheet and paste A1 to C3 at the same location on the new sheet

    and I need this to create a new sheet and do that everytime the button is pressed

    can someone help me with this?




    I've tried creating a shape and assigning a recorded macro to it where i did this:
    1. create a new sheet (this part worked)
    2. copy data (this worked)
    3. pasted onto new sheet (did NOT work, instead it kept pasting onto the same sheet and 2 lines below the older version)
    Last edited by torontoguy; 01-30-2009 at 11:43 AM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Please Login or Register  to view this content.
    Change Sheet1 to the sheet to copy

    you can add a button from the forms toolbar and right click > assign macro

    http://www.bettersolutions.com/excel...B215612321.htm

    Edit

    or

    Please Login or Register  to view this content.
    VBA Noob
    Last edited by VBA Noob; 01-14-2009 at 09:36 AM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    ive got

    Please Login or Register  to view this content.
    also, another question is... can i create a button that copies data and pastes it directly under

    say I copy A1 to B10

    can I create a macro that will copy that and paste it at like... D1 to E10 the next time
    and then the next time I click, it will create it at G1 to H10 (keeps going but leaves a space in between them)
    Last edited by torontoguy; 01-14-2009 at 09:57 AM.

  4. #4
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    is that what you meant?

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    say I copy A1 to B10

    can I create a macro that will copy that and paste it at like... D1 to E10 the next time
    and then the next time I click, it will create it at G1 to H10 (keeps going but leaves a space in between them)
    Don't follow. You are now saying copy from Sheet A to Static Sheet B?

  6. #6
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    No sorry. What Im trying to do now is in just 1 Sheet

    Copy rows A and B to rows C and D with the click of a button
    and everytime the button is clicked, copy rows A and B in the next available set of rows (next one in this case would be E and F)

    (we can do spacing later because I believe that's the easier part)

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    Please Login or Register  to view this content.
    or with the extra row

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    that sort of worked, thanks for that
    but this is the problem now:

    on my first click, it created rows A and B on rows C and D
    however, when I clicked multiple times after, it kept creating it on rows C and D

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try attached example
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    yes

    this seems to work

    Please Login or Register  to view this content.
    if I would like to expand this to say copy the first 100 rows, would I just change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Need to change the resize as well

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72
    Excellent. Thanks.

+ 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