I am copying individual cells from excel and pasting it into SQL. Each time I do it, carriage return is automatically added to copy.


Enter 123 in any cell in excel 2007.Click on another cell. Now right click on the cell you just entered. Select copy. Open notepad and paste. Note that carriage return is also copied, where there is no carriage return in the cell.

1 Answer 1


I believe you'd want the carriage return if you were copying more than one cell, which is probably why it's being included.

But if you're copying one at a time, you can copy from the formula bar instead of from the cell then you won't get the carriage return.

If you have a lot of cells to copy, you might want to create a simple VBA script to push the contents of the selected cell into the clipboard (then assign that to a hotkey).


Example macro:

Sub CopyActiveCell()
    Dim objData As MSForms.DataObject
    Set objData = New MSForms.DataObject
    objData.SetText ActiveCell.Value
End Sub

Note that for that to work you need to add a reference to Microsoft Forms 2.0 Object Library (via Tools | References). If you're copying many values, you could make it even simpler by adding creating the sub in the Sheet1 module as

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

instead of

Sub CopyActiveCell()

That will automatically copy the cell value whenever you click once on a cell to select it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .