Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Excel Copy paste without quotes

Tags:

Problem 1:

How to copy paste cell values from Excel file without copying the quotes(" & ")?

Problem 2:

Next line chars are also ignored while pasting

Excel File Text:

Excel Text

Text after Paste:

Pasted Text

PS: The only way I can do it without quotes is, by first pasting value in MS Word and then paste it in text file from MS Word file.

like image 274
Kylo Ren Avatar asked May 03 '16 09:05

Kylo Ren


People also ask

Why are there quotation marks when I copy and paste from Excel?

In my experience, when I copy paste from excel to a text file, it will add quotation marks if the cell has multiple lines.

How do you stop quotation marks in Excel?

To do this, select the column of data that has the extra quote marks, then go to the “Data” tab and click “Text to Columns.” In the “Text to Columns” wizard, select “Delimited” and click “Next.” Then, uncheck the “Tab” option and check the “Other” option.

How do I copy and paste in Excel without messing up formatting?

To use this shortcut, simply select the cell where you want to paste the text. Then, press Ctrl + Shift + V on your keyboard. This will paste the text without any formatting. If you want to paste the text and keep the formatting, you can use the Ctrl + V shortcut instead.


1 Answers

Well there's nothing much you can do about it. However there is a work around for it.

You can use CLEAN function as =CLEAN(A1) (specify your cell address). Then copy the text to notepad and you'll get the desired result.

But CLEAN function also erases line breaks from text as this function removes all nonprintable characters from text.

EDIT1: _________________________________________________________________________________

enter image description here

This is the difference in result after copying.

enter image description here


EDIT2: __________________________________________________________________________________

Here is a VBA solution. Try the following code:

Sub CopyToNotepad()
    Dim objData As New DataObject  'set reference to Microsoft Forms 2.0 Object Library
    Dim strTemp As String
    Dim i As Long, FN As Integer
    Dim FilePath As String, FileName As String
    Dim MyRange As Range
    Dim cell As Variant

    FilePath = "C:\test file\"   '---> give your file path
    FileName = "test.txt"        '---> give your file name
    FileName = FilePath & FileName
    FN = FreeFile

    Open FileName For Output As #FN

    Set MyRange = Worksheets("Sheet1").Range("A3:A5")
    For Each cell In MyRange.Cells
        strTemp = Replace(cell.Value, Chr(10), vbCrLf)
        objData.SetText (strTemp)
        Print #FN, strTemp
    Next

    Close #FN
End Sub

To use the DataObject in your code, you must set a reference to the Microsoft Forms 2.0 Object Library.

This will give you output like below image: enter image description here

like image 159
Mrig Avatar answered Sep 28 '22 03:09

Mrig