+ Reply to Thread
Results 1 to 2 of 2

How to Copy and Paste a Selected Portion of Text?

  1. #1
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    How to Copy and Paste a Selected Portion of Text?

    I have an Excel sheet which includes many large blocks of text. I'd like to create a macro that allows users to copy a selected portion of text, and paste (append) that selected text into a specific column (in the same row as the selection). For example, suppose cells C6, D6, and E6 contain large blocks of text. I want to manually select a portion of that text (let's say 5 or 6 words within cell D6), and then click a macro button (or use a shortcut key) to automatically copy and paste that selected text into cell $J6.

    I'm not sure how the Selection property will work. If I manually select a portion of the text in cell D6, will Selection.Copy copy only the selected text, or all of the text in that cell? And if (as I'm hoping) Selection refers to the text, then how can I also (at the same time) figure out which row I'm working with? Will Selection.Row still give me the row number, if Selection is referring to the text and not to the range?

    On a related note, what will Selection.TypeName be, if a portion of text is selected? I know TypeName = "Range" if a cell is selected. Will TypeName = "String" if text is selected?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to Copy and Paste a Selected Portion of Text?

    You can't run code when in edit mode, and to select text within a cell you would have to be in edit mode.

    Also, as soon as you leave a cell, and edit mode, you would lose the selection.

    I think the best you could do is to have the user select and copy the text.

    That would put the text on the clipboard and you could work from there, for example this should paste what's on the clipboard to J6.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ 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. Macro to copy- paste a portion of a clomun
    By Memo14 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-10-2014, 11:56 AM
  2. [SOLVED] Macro to Copy the Portion of text in Cell
    By mvel_sky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2014, 01:45 PM
  3. [SOLVED] Need MACRO to copy the text in the cell left of first selected cells (a column), paste all
    By joobeng in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-16-2013, 06:42 AM
  4. Copy and paste the template to the next portion of the screen, VBA
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2012, 12:26 PM
  5. Replies: 10
    Last Post: 02-02-2012, 07:03 PM
  6. cut a portion of a cell's contents and paste the cut portion into the net column
    By NJEvan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-12-2010, 05:08 AM
  7. copy data from selected cells , in selected row and paste it to ms word table ?
    By aaashaaa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2010, 03:25 PM

Tags for this Thread

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