+ Reply to Thread
Results 1 to 18 of 18

command button not pasting.

  1. #1
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    command button not pasting.

    this should be a really simple one for experienced excel users but me I'm very much the novice.
    I've created a command button that should cut and paste A1:O83 and paste to A:86 and it does, but I'm having trouble getting it to paste all my drop downs, formulas, fonts and colors.

    if I hit the command button it does copy and paste, but only some of the drop downs and none of the formulas or font/colors.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: command button not pasting.

    Welcome to the Forum julesjcombe!

    If you are doing this with a button, you must be using VBA when you click the button. You need to show all of the VBA code you are using.

    When you paste your VBA code, use code tags. There are two ways to add code tags. One is to select the code part of the text so it is highlighted, then press the "#" button in the edit controls. The other is to simply type in the tags:

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]


    Why use code tags? Code tags:

    1. Are required by rules (see rule #2)
    2. Preserve spacing used to show code structure (otherwise leading spaces and repeated spaces are removed)
    3. Add scroll bars to navigate code with long lines or a lot of lines
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    I didn't write the code and please because I might be saying really silly things here but what are code tags?
    I purely copied the code and edited it to make it work, well partly work?

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,012

    Re: command button not pasting.

    .
    He meant ... to post your code here so we can study what the goal is and how it is working, click on the pound sign in the REPLY MENU.

    Be certain all of your code shows up between the two HTML Tags [ CODE ] Your code goes here [ / CODE ]

  5. #5
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    Private Sub CommandButton1_Click()
    Application.ScreenUpdating = False
    Dim xSheet As Worksheet
    Set xSheet = ActiveSheet
    If xSheet.Name <> "Definitions" And xSheet.Name <> "fx" And xSheet.Name <> "Needs" Then
    xSheet.Range("A1:O83 ").Copy
    xSheet.Range("A86").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End If

    Application.ScreenUpdating = True
    End Sub

  6. #6
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    BTW I've tried to add Paste:=xlValuesAndNumberFormating etc

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,012

    Re: command button not pasting.

    .
    The use of "Paste:=xlValues" refers to cells with formulas.

    If you do not have formulas in that range of cells A1:O83 ... you can use :

    Please Login or Register  to view this content.
    Last edited by Logit; 04-28-2021 at 10:12 AM.

  8. #8
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    yeah well its coping and pasting but the formulas and drop down list as well as cell color and fonts need to be copied and pasted and this is not happing with this current VBA nor did it work with Paste:=xlVavuesAndNumberFormating

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,012

    Re: command button not pasting.

    .
    Try this :

    Please Login or Register  to view this content.
    Because you used the term "ActiveSheet" ... I presumed you wanted the same range copied and pasted from each sheet except those not in the list.
    This macro should repeat the action on all sheets not listed.

  10. #10
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    no sorry now its not pasting anything its just blank?

  11. #11
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    so in design mode I can see my button is =EMBED("Forms.CommandButton.1","")
    so does this mean I need to remove it and start over to get it working correctly?

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,012

    Re: command button not pasting.

    That doesn't make any sense. It works here.

    Look at the attached.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    well you don't have and formulas in the cells and I've just put a drop down and and an equals sum and in your data and it only copies a blank cell where the drop down is? and only copies the result of the sum not the formula?

    colors TICK
    fonts TICK
    general copy and paste TICK
    formulas copy and paste NO
    drop down lists copy and paste NO

    am I asking to much can it be done at all?

  14. #14
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,012

    Re: command button not pasting.

    Yes it can be done.

    It is very late here at the moment and I'm falling asleep at the computer. If someone else doesn't provide an answer by tomorrow, I will.
    Hope you understand.

    Have a good day.

  15. #15
    Registered User
    Join Date
    04-27-2021
    Location
    Bendigo, Australia
    MS-Off Ver
    windows 10
    Posts
    9

    Re: command button not pasting.

    yeah dam I didn't realize you where in the States, go to bed ill get it sorted tomorrow with ya help.

  16. #16
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: command button not pasting.

    Hello Jules,

    My offering to you:-

    Please Login or Register  to view this content.
    As you're operating (copy/paste) each time on an Activesheet, I don't see the need to exclude other sheets as per your code in post #5.

    I hope that this helps.

    Cheerio,
    vcoolio.

  17. #17
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: command button not pasting.

    Quote Originally Posted by julesjcombe View Post
    Private Sub CommandButton1_Click()
    I gave detailed instructions in post #2 about how to use code tags when you put code into a forum post. The rules require it. Please edit your post to add code tags.

    No further posts are permitted in this thread until this moderation request has been fulfilled.

  18. #18
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: command button not pasting.

    Quote Originally Posted by julesjcombe View Post
    Private Sub CommandButton1_Click()
    Quote Originally Posted by Logit View Post
    Private Sub CommandButton1_Click()
    I gave detailed instructions in post #2 about how to use code tags when you put code into a forum post. The rules require it. Please edit your posts to add code tags.

    No further posts are permitted in this thread until this moderation request has been fulfilled.

+ 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. [SOLVED] Copying ActiveX Command Button from master sheet to subsheets. command button code missing
    By popper08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2020, 10:15 AM
  2. Pasting to next available cell with command button
    By mdir325 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2018, 03:54 AM
  3. Replies: 2
    Last Post: 02-02-2016, 10:27 PM
  4. Insert Command Button that will Activate Command Button on a Different Sheet
    By realvirtuality1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2016, 02:11 PM
  5. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  6. Replies: 1
    Last Post: 09-17-2007, 09:57 PM
  7. Replies: 0
    Last Post: 11-03-2005, 11:00 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