+ Reply to Thread
Results 1 to 7 of 7

Copy to clipboard button on / paste special button.

  1. #1
    Registered User
    Join Date
    01-24-2007
    Location
    Melbourne, Australia
    Posts
    79

    Copy to clipboard button on / paste special button.

    I have no excel programming experience whatsoever, but I need to put a button on my workbook that will copy the contents of a cell to the clipboard, then I want to put another button on another workbook to "Paste special (VALUE)" into a particular cell.
    Can this be done?
    *NOTE - This is for 2 different workbooks, not 2 sheets within the same workbook.

  2. #2
    Registered User
    Join Date
    12-17-2008
    Location
    Chicago, IL
    MS-Off Ver
    2007
    Posts
    14
    In the first workbook you could put
    Please Login or Register  to view this content.
    Right click the button, assign macro, and pick that sub.

    In the second workbook you would put
    Please Login or Register  to view this content.
    Then assign this to the button in the second workbook.

    If you don't paste it right away you could lose it, and would then get an error. The ErrorHandling stuff would just exit the sub and amount to the macro doing nothing (instead of VB popping up with the error).
    Last edited by royUK; 12-17-2008 at 04:48 AM.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    jdwilson:
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I will add them this time.
    Hope that helps.

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

    Free DataBaseForm example

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You don't need two sets of code or buttons, nor even the clipboard. You don't even need code if it is always the same cells & workbooks. This code assumes both workbooks are open, it can be adapted to open the other workbook
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-24-2007
    Location
    Melbourne, Australia
    Posts
    79
    Thanks guys, I used jdwilson's code, only because the people that are going to be using this may not aways have both sheets open.
    I wonder if you can help me, could you write code that copy's cell A1 to the clipboard and converts it to a value, so that when they go into the other sheet they can just do a ctrl-v. (I need to keep it simple for the computer illiterates in my office.)
    Or maybe the code could copy cell A1, paste special (VALUES) into A2 and then copy A2 to the clipboard. Am I making sense?

    EDIT: I just found another problem, the cell I am copying is 3 merged cells. Eg. Cell A,B,C1 (cell A1, B1, and C1 merged) and when I try to copy it into the other book I get the error about it not being identically sized. How would I change the code to copy the 3 cells (merged) instead of just one?
    Last edited by jasonmcbride; 12-17-2008 at 08:27 PM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You should avoid Merged Cells, use centre across selection from the format menu instead.

    The code that I gave you doesn't need pastespecial as values, & as i said it can be adapted if the other workbook needs opening.

  7. #7
    Registered User
    Join Date
    12-17-2008
    Location
    Chicago, IL
    MS-Off Ver
    2007
    Posts
    14
    You could use Range("A1:C1"). When pasting, try Activesheet.Paste, after selecting a single cell.

+ 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