+ Reply to Thread
Results 1 to 2 of 2

I need to export specific columns to a pipe delimiter file instead of entire worksheet.

  1. #1
    Registered User
    Join Date
    08-14-2013
    Location
    Kentucky, United States
    MS-Off Ver
    03,07,10
    Posts
    61

    Exclamation I need to export specific columns to a pipe delimiter file instead of entire worksheet.

    I am trying to export columns A,C,E & L from my worksheet into a pipe delimited file. This is what I have so far however it only exports the entire file not the specified columns.

    Option Explicit

    Sub SaveAsPipeDelimited()
    Const DELIMITER As String = "|"
    Dim myRecord As Range
    Dim myField As Range
    Dim nFileNum As Long
    Dim sOut As String

    nFileNum = FreeFile
    Open "Test.txt" For Output As #nFileNum
    For Each myRecord In Range("A2,A:A,C:C,E:E,L:L").Select
    Range("L1" & Rows.Count).End(xlUp).Row)
    With myRecord
    For Each myField In Range(.Cells, _
    Cells(.Row, Columns.Count).End(xlToLeft))
    sOut = sOut & DELIMITER & myField.Text
    Next myField
    Print #nFileNum, Mid(sOut, 2)
    sOut = Empty
    sOut = Empty
    End With
    Next myRecord
    Close #nFileNum

    End Sub

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: I need to export specific columns to a pipe delimiter file instead of entire worksheet

    Try something like

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 05-02-2013, 11:16 AM
  2. VBA macro for Inserting text file(having pipe as delimiter) into Excel sheet
    By Nusrat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2013, 05:40 AM
  3. Replies: 1
    Last Post: 12-02-2007, 05:52 AM
  4. [SOLVED] export excel file as csv with text delimiter of "
    By John in forum Excel General
    Replies: 2
    Last Post: 05-12-2005, 01:06 PM
  5. Pipe Delimiter
    By Guido in forum Excel General
    Replies: 0
    Last Post: 04-20-2005, 10:33 AM

Tags for this Thread

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