+ Reply to Thread
Results 1 to 7 of 7

Save in Excel with Commas

Hybrid View

  1. #1
    Registered User
    Join Date
    05-16-2009
    Location
    miami
    MS-Off Ver
    Excel 2007
    Posts
    5

    re: Save in Excel with Commas

    shg,
    I am not much of a programer. how do you run the program in
    http://www.excelforum.com/excel-prog...le-string.html
    Thanks again

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    re: Save in Excel with Commas

    Sub TextOut()
        Const sFile As String = "C:\YourPath\YourFileName.txt" ' change as required
        
        Dim cell    As Range
        Dim iFF     As Integer
        Dim s       As String
    
        For Each cell In Selection
            s = s & cell.Value & ","
        Next cell
        s = Left(s, Len(s) - 1)
    
        iFF = FreeFile
        Open sFile For Output As #iFF
        Print #iFF, s;
        Close #iFF
    End Sub
    Adding a Macro to a Code Module
    1. Copy the code from the post
    2. Press Alt+F11 to open the Visual Basic Editor (VBE)
    3. From the menu bar in the VBE window, do Insert > Module
    4. Paste the code in the window that opens
    5. Edit the sFile string to be the correct path
    6. Close the VBE to return to Excel

    Then ...

    Select the cells you want to output to the file

    Do Alt+F8 and run macro TextOut
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1