PDA

View Full Version : Paste Multiple lines into single Cell



mivanows
11-25-2009, 10:02 AM
I manually am copying multiple line text from VBE Modules (comments) and paste into a single cell in Excel. See the steps:
In VBE Modules select multiple lines.
Copy
In Excel: Select a cell, press {F2} and paste.
How can I write a code to edit Cell {F2} and paste?
I tried the follow and did not work (it pasted to multiple cell instead a single cell)

Sub EditPaste()
'Edit Cell and Paste whatever is in the Clipboard.and UnWrap
ActiveCell.Select
Application.SendKeys "{F2}"
ActiveSheet.Paste
Application.Run "PERSONAL.XLSB!UnWrap"
End Sub

lucas
11-25-2009, 11:14 AM
maybe:

ActiveCell.FormulaR1C1 =

mdmackillop
11-27-2009, 06:59 AM
Try this

Sub AllInOne()
Dim i As Long, txt As String
ActiveSheet.Paste
For i = 1 To Selection.Cells.Count
txt = txt & Selection(i) & Chr(10)
Next
Selection.ClearContents
Selection(1) = txt
End Sub