#1
|
|||
|
|||
Macro to Insert Text Into Cells Having Multiple Lines
I need help with a macro to insert copied text to the end of a string of multiple lines that are already in a cell by utilizing the Alt Enter combo.
For example, a cell which already contains the following: The quick red fox jumped over would look like this: The quick red fox jumped over the lazy brown dog. after I copy "the lazy brown dog." to the clipboard and then click on the cell and press Ctrl i. |
#2
|
|||
|
|||
And you cannot simply double click the cell and just press Ctrl +V instead of Ctrl+I?
|
#3
|
|||
|
|||
Double clicking just lets me paste into the cell wherever the cursor happens to be. It does not insert the Alt Enter code to make the new line.
Also, I need a macro because I am going to modify it with additional VBA code. |
#4
|
|||
|
|||
Try this code then... (you need to set a reference to the Microsoft Forms 2.0 Object Library... To add a reference to your VBA project, go to the Tools menu in the VBA editor and choose the References item. In the dialog that appears, scroll down the list until you find the appropriate library )
Code:
Sub paste() Dim DataObj As New MSForms.DataObject Dim S, T As String DataObj.GetFromClipboard T = ActiveCell.Value S = DataObj.GetText ActiveCell.Value = T & " " & S End Sub |
#5
|
|||
|
|||
Thank you for the reply. So how would I insert the "Alt Enter" to force a new line?
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to Insert a Clear, Blank page without Lines and Numbers in a Pleading Document | Dirigo | Word | 5 | 09-30-2011 08:08 AM |
Multiple VLOOKUP's checking multiple Cells | OTPM | Excel | 11 | 05-23-2011 11:18 AM |
filling multiple cells whislt using Filter | VinceO | Excel | 1 | 05-09-2011 06:38 AM |
How to organize and insert blank cells between a huge number of data? | tareq | Excel | 12 | 09-29-2010 02:12 PM |
Horizontal lines won't insert into full margins set in a doc. | rec | Outlook | 2 | 06-14-2010 09:47 AM |