Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Getting Rid of Extra Quote Marks in Exported Text Files.

Getting Rid of Extra Quote Marks in Exported Text Files

by Allen Wyatt
(last updated March 12, 2018)


Sometimes the export filters used by Excel can produce undesired results in the exported file. For instance, when you export to a tab-delimited text file, some Excel filters place quote marks around the text in a cell. For instance, assume that a particular cell contains the following text:

Create bts; sitemask = "0110"; pcmlink = 40 

This, however, is how the text in the cell is exported by Excel:

"Create bts; sitemask = ""0110""; pcmlink = 40" 

Notice that Excel adds extra quotation marks, first around the entire cell contents, and then an extra set around any previously "quoted" text within the cell.

One solution for handling the problem is to simply load the text file created by Excel into another program, such as Word, and use the Find and Replace feature to remove the undesired quotes. A better solution, however, is to create your own macro that creates the output text file. Consider the following macro:

Sub Export()
    Dim r As Range, c As Range
    Dim sTemp As String

    Open "c:\MyOutput.txt" For Output As #1
    For Each r In Selection.Rows
        sTemp = ""
        For Each c In r.Cells
            sTemp = sTemp & c.Text & Chr(9)
        Next c

        'Get rid of trailing tabs
        While Right(sTemp, 1) = Chr(9)
            sTemp = Left(sTemp, Len(sTemp) - 1)
        Print #1, sTemp
    Next r
    Close #1
End Sub

All you need to do is select the cells you want to export, and then run the macro. The cells in the selection are extracted from the worksheet and placed in the file c:MyOutput.txt. (This filename can be changed in the macro to whatever your needs dictate.)


If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2237) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Getting Rid of Extra Quote Marks in Exported Text Files.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Merging to Individual Files

The mail-merge feature in Word is a fast, easy way to create form letters addressed to many different people. Sometimes, ...

Discover More

Disappearing Graphics Groups

Grouping graphics together can be a great way to manage them easier. Doing the grouping, however, could have unintended ...

Discover More

Summing Every Fourth Cell in a Row

Need to sum a series of cells that fits some regular pattern? Here are several ways that you can get the summation that ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (menu)

Making Changes in a Group of Workbooks

If you need to change the same data in a large number of workbooks, the task can be daunting. Here are some ideas (and ...

Discover More

Error Opening Second Workbook

If you try to open a second workbook and you see an error message, it could be because of the way you are opening the ...

Discover More

Appending to a Non-Excel Text File

Does your macro need to add information to the end of a text file? This is called appending, and is done using the ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 2?

2020-01-27 17:31:05



i would like to extract email by using excel vba. however, there have quotation mark in subject line. my code as below
i am using workday function in vba, however, the actual subject line is my docu "2020-01-023" report. there have quotation mark before and after the date. how can solve the issue? Thank you so much

Set olApp = CreateObject("Outlook.Application")

Dim olNs As Outlook.Namespace
Dim fldr As Outlook.MAPIFolder
Dim olMail As Outlook.MailItem

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set fldr = olNs.Folders("myfolder").Folders("Inbox")
Set mytasks = fldr.Items

Dim mydate as string
Dim mydocu as string

mydate = Format(CDate(Evaluate("workday(today(),-1)")), "yyyy-mm-dd")

Set olMail = mytasks.Find("[Subject] = ""my docu " & mydate & " report""")

mydocu = "my docu " & mydate & " report"

olMail.SaveAs "C:\mypath\" & mydocu & ".msg"

2019-01-18 12:32:10

Matthew Hermez

what if I have single line that has double and quad quotes and at the end I should only keep double quotes from the quad quotes. when I export to text file I am getting new quotes one at the beginning and one at the end also added extra quotes to an existing quotes.

I am using this command to export to textv

Sub ExportSheetsToText()
Dim xWs As Worksheet
Dim xTextFile As String
For Each xWs In Application.ActiveWorkbook.Worksheets
xTextFile = CurDir & "" & xWs.Name & ".txt"
Application.ActiveWorkbook.SaveAs filename:=xTextFile, FileFormat:=xlText
Application.ActiveWorkbook.Saved = True

End Sub

and getting below results
"BKUP-PLD:::::PLD_BACKUP_FILE_REF=""/log/conf/ENB/xxxxx/eNBxxxxx_backuppld.tar.gz""; 1"

I should get rid of edge quotes and get rid of extra quotes added to (/log/conf/ENB/xxxxx/eNBxxxxx_backuppld.tar.gz) and leave one set of quotes only for that sentence so it will be (BKUP-PLD:::::PLD_BACKUP_FILE_REF="/log/conf/ENB/xxxxx/eNBxxxxx_backuppld.tar.gz"; 1)

Thank you

2016-04-24 16:10:52

Dave N

Marvelous! Thanks so much. Now in 2016 it's STILL a problem. And with a little 'Export' button added, linked to the macro, perfection!

2016-01-14 07:01:18

Ben U

Brilliant, thank you

2015-08-28 14:53:57


Thank you!!!

2015-05-08 17:36:11

Robert W

The easiest solution I have found is to just open the Excel spreadsheet and highlight what you want (even the entire spreadsheet) and then copy & paste it directly into NotePad.

2015-05-01 10:42:51

Apoorv S

Thanks a lot.. I have been searching a solution for this issue for sometime now. This code worked like a charm.

2015-03-10 12:48:08


Hi! i am trying to use your suggestion. I am having a text file and I want to Output that using the VBA in MS Excel. When I use the Output command, I am getting a "Permission Denied: Error 70" error. I believe this is because I am trying to Output a write-protected text file. Can you suggest me the vba code required to remove the write-protection on this text file. This would help me a lot and I greatly appreciate it.

2014-12-16 09:24:46


Amaising Macro

2014-11-19 04:52:16


Above code worked for my problem...Thank you...But small doubt what is WEND in the above code?

2014-11-19 02:26:11


If i convert excel file into csv, when i open that converted file in notepad it is showing some extra double quotes. how can i remove this quotes?

2014-10-30 14:23:34


Or do it the easy way. Export the file as CSV. Edit it using Notepad. Remove all the Quotes and save it. Done.

2014-07-23 16:28:17

john s

This is an excellent tip!

2014-06-18 12:20:33


Also found a lot of crappy "solutions" on the internet, before this one!!! I new I had to do something with the [Print] command...
In addition, I only needed to start with replacing my existing qoutes:

Cells.Replace What:="""", Replacement:="'", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

2014-03-26 16:34:52


Is there anyway to do this on just a single column within an existing macro?

I have an exported webpage in Excel that we run a lengthy macro on, but still has hidden quotations on only 1 column (G) that we manually find/replace via the text file.

I would like to be able to add this into the existing macro for column G only.

I'm teaching myself VB so I would appreciate any assistance!


2013-11-07 16:25:32

Sam A

This worked great. Thanks!
One alteration I made was to open the file after saving it(at the very end). To do this I added the following code at the end(See full example below): Shell "notepad++.exe ""c:tempMyOutput.txt""", vbNormalNoFocus

Sub Export()
Dim r As Range, c As Range
Dim sTemp As String

Open "c:tempMyOutput.txt" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c

'Get rid of trailing tabs
While Right(sTemp, 1) = Chr(9)
sTemp = Left(sTemp, Len(sTemp) - 1)
Print #1, sTemp
Next r
Close #1
Shell "notepad++.exe ""c:tempMyOutput.txt""", vbNormalNoFocus
End Sub

2013-10-31 00:23:14


Thanks! This is great. Have been struggling with this for a couple of weeks and you have solved it!

2013-09-24 00:09:15


Thank you so freaking much for this elegant and effective macro! This page just ended two hours of frustrated google searches.

2013-08-19 05:36:49

Bruno V

Hi, interesting tip. Excel also puts quotation marks around email addresses one wants to copy into the TO-line of Outlook when there is more than one email address in a cell. Can this macro be adapted to remove the quotation marks while transiting through the clipboard?

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.