Excel saving a file witout quotations

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,460
Office Version
365
Platform
Windows
Using the techniques shown here: https://analysistabs.com/vba/vba-write-string-text-file-without-quotes/

The code would look something like this:
Code:
Sub ExportData()

    Dim lr As Long
    Dim r As Long
    Dim myFileName As String
    Dim cellValue As Variant
    
    Sheets("Olink").Select
    
'   Find last row with data in column P
    lr = Cells(Rows.Count, "P").End(xlUp).Row
    
'   Prompt for full file path and name
    myFileName = Application.GetSaveAsFilename(fileFilter:="PRN (*.prn), *.prn")
    
'   Create new file
    Open myFileName For Output As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] 
    
'       Loop through all rows in column P
        For r = 1 To lr
'           Capture value of cell
            cellValue = Cells(r, "P").Value
'           Write to text file
            Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , cellValue
'       Move to next row
        Next r
'   Close text file
    Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] 

    MsgBox myFileName & " created"

End Sub
Note that there isn't any need to copy the data to a new sheet to do this. We can do it from column P on the Olink sheet.
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

5h1v

Board Regular
Joined
Oct 11, 2012
Messages
66
Just tried this and it works perfectly, thank you so much this will save me so much time removing the excess characters.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,460
Office Version
365
Platform
Windows
You are welcome.
Glad I was able to help!
 

Watch MrExcel Video

Forum statistics

Threads
1,099,608
Messages
5,469,669
Members
406,665
Latest member
priyankape2005

This Week's Hot Topics

Top