+ Reply to Thread
Results 1 to 20 of 20

Create string to copy to clipboard

  1. #1
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Create string to copy to clipboard

    Hello,
    I'm looking for a code to trigger on Worksheet_SelectionChange.

    The code will simply copy a string to the clipboard. The string should consist of "http://xyz.com/" and Target.Value.

    In the end, the copied text needs to be "http://xyz.com/textfromtargetcell"

    Also, this only needs to work for a particular range (ie: F17:F1000)

    Any help would be appreciated!

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Create string to copy to clipboard

    Please Login or Register  to view this content.
    Last edited by nigelog; 02-06-2019 at 09:57 AM.

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: Create string to copy to clipboard

    Try this:

    Please Login or Register  to view this content.
    It need 'Microsoft Forms 2.0 Object Library' in VBA.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Create string to copy to clipboard

    Try this
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  5. #5
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    Wow, thank you all for the help. Unfortunately none of them are working!

    There must be something else happening.

    I do have the Reference library installed. Using YasserKhalil's code above, when I select multiple rows in column F I get a debug error (as I would expect), however, when I click on one it does not copy to the clipboard. None of the code above copied to the clipboard. So strange.

    For the record, I'm using Win 10 64 bit, Office 365.

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Create string to copy to clipboard

    You can avoid the error of selecting multiple rows using this line
    Please Login or Register  to view this content.
    But I don't why it doesn't work for you as for copying the string to the clipboard

  7. #7
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    Interesting, when I paste into Notepad, it shows nothing. When I paste here, it shows nothing. When I paste into Word I get two squares with checkmarks in them. (here they are copied from Word ￿￿)

    Also, I'm afraid your second bit of code didn't fix that either.. Runtime error 13 Type mismatch

    Thank you again for your help with this.

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Create string to copy to clipboard

    Please Login or Register  to view this content.
    pastes to word and notepad

  9. #9
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    Nigelog, thank you, your code does work in a new blank workbook. Yet, it doesn't work in my current file. I will say that upon opening the file, several queries and pivot tables refresh. The sheet in question does contain a pivot table, and the table from which I'm trying to copy does contain conditional formatting.

    I don't see how it's possible, but I suppose one of these could be causing the issue.

  10. #10
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Create string to copy to clipboard

    maybe upload a sample workbook?

  11. #11
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    I tried breaking down my file and removing a whole bunch of data, and it started working.
    I think the issue boils down to the cell having a formula in it, and not just text. After I deleted all my queries, my formulas became #REF and then VBA started erroring out upon click. Sound possible? When I remove the #REF and change it to a text word it works.

    Is there a way to change Target.Value to Target.TextValue or something?

  12. #12
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Create string to copy to clipboard

    try Target.Value2 and see if that works

  13. #13
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    try Target.Value2 and see if that works
    No such luck I'm afraid

  14. #14
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Create string to copy to clipboard

    can you try moving the formula to vba? like so:

    Please Login or Register  to view this content.
    that should put the formula result in what ever range you want.

  15. #15
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    Quote Originally Posted by dmcgov View Post
    can you try moving the formula to vba? like so:

    Please Login or Register  to view this content.
    that should put the formula result in what ever range you want.
    That would be really difficult, maybe impossible. It's part of a table 1000 rows deep.

  16. #16
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Create string to copy to clipboard

    longshot but worth a try
    Please Login or Register  to view this content.
    works on formulas here. See table
    Attached Files Attached Files
    Last edited by nigelog; 02-06-2019 at 12:46 PM.

  17. #17
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    I've seen this code on a different website? Would somebody be able to help me incorporate it into mine? (the part pertaining to converting the clipboard to text)
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    Quote Originally Posted by nigelog View Post
    longshot but worth a try
    Please Login or Register  to view this content.
    works on formulas here. See table
    Your file does the same thing on my end. I click 29 in your table and then paste to a different cell and it puts the two ?? boxes in the cell. This is infuriating! I really do appreciate your help though. Thank you.

  19. #19
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Create string to copy to clipboard

    Please Login or Register  to view this content.
    that appears to just be clearing the clipboard
    Think you need to post a workbook

  20. #20
    Forum Contributor her.rockstar's Avatar
    Join Date
    01-11-2013
    Location
    Saint John, NB
    MS-Off Ver
    Office 365
    Posts
    194

    Re: Create string to copy to clipboard

    Quote Originally Posted by nigelog View Post
    Please Login or Register  to view this content.
    that appears to just be clearing the clipboard
    Think you need to post a workbook

    Well I've narrowed it down even further. The code below works after I delete several worksheets. Doesn't seem to matter what kind of content is in the cell, whether it's a formula or text. If it's a formula, it just copies the text.
    HTML Code: 
    The issue is definitely related to the size of the workbook.
    Last edited by her.rockstar; 02-06-2019 at 01:37 PM.

+ 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. Copy From Clipboard to Find Value on Pivot Table, Copy to Different Cell
    By msdcanto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2018, 01:21 PM
  2. Saving String to Clipboard from Message Box
    By justaddculture in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2016, 05:23 AM
  3. [SOLVED] VBA copy String to Clipboard
    By wambaugh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-08-2015, 08:48 AM
  4. Replies: 2
    Last Post: 01-02-2013, 08:35 AM
  5. Macro validate string copied to Clipboard
    By petreli in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-17-2012, 05:51 AM
  6. Create mail with body from clipboard
    By tonywig in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2008, 04:37 AM
  7. [SOLVED] Putting plain text string into clipboard in VBA?
    By Don Wiss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-22-2005, 06:06 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