+ Reply to Thread
Results 1 to 4 of 4

Copy to clipboard help

  1. #1
    Registered User
    Join Date
    10-08-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003/2007
    Posts
    3

    Copy to clipboard help

    Hey gang,

    I've been searching for hours but can't seem to be able to figure out my problem. I'm trying to set up a system where a user can click on a link in a cell, and that link will direct them to a specific cell in another sheet where it will copy that cell to the clipboard. The code below is what I'm currently using, and while it does work, the problem I run in to is that when you initially open up the spreadsheet, if you instantly click on a link, it's not copying. I'm relatively new the VBA world, and I have a feeling my issues stem from activecell, or lack thereof. Any ideas?

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Target.Copy
    Sheets("Comment Code").Select
    End Sub

    For whatever it's worth, column A in sheet 1 is for a numeric code (1-50), and in sheet 2, all of the comments that correspond to said codes are listed. The idea is that the user can click on the necessary code, 1 for example, and it would copy the comment for code 1 that's listed in sheet 2 to the clipboard for them to paste in a separate application.

    I realize this post was a bit lengthy, as well as confusing, but I just can't figure it out.

    Thanks!

  2. #2
    Registered User
    Join Date
    10-08-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003/2007
    Posts
    3

    Re: Copy to clipboard help

    bump. Any help/insight would be great! Thanks!

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Copy to clipboard help

    Hi rtsylvia,

    The event you have your code on it "SelectionChange". If the event isn't being triggered then your code won't run. Try putting your code on a different event. I normally use "BeforeDoubleClick" that takes a mouse double click to run the code.

    Read http://excel.tips.net/Pages/T003070_...nt_in_VBA.html for more on SelectionChange events.

  4. #4
    Registered User
    Join Date
    10-08-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2003/2007
    Posts
    3

    Re: Copy to clipboard help

    Quote Originally Posted by MarvinP View Post
    Hi rtsylvia,

    The event you have your code on it "SelectionChange". If the event isn't being triggered then your code won't run. Try putting your code on a different event. I normally use "BeforeDoubleClick" that takes a mouse double click to run the code.

    Read http://excel.tips.net/Pages/T003070_...nt_in_VBA.html for more on SelectionChange events.
    Oh man, I didn't even think about that! So the reason why my code wouldn't always work was because the event wasn't occurring.. I'll try out the "BeforeDoubleClick" and see how that works. Thanks so much for the help!

+ 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