Quantcast
Channel: Excel VBA Codes & Macros
Viewing all articles
Browse latest Browse all 52

Export Range to Pipe Delimit Text File

$
0
0
Macro to export range to pipe delimit textfile -


Option Base 1
Option Explicit

Sub export_range_pipe_delimit()
Dim arr As Variant
Dim i As Long, j As Long
Dim line As String
Dim filename As String
Dim rng As Range
Dim fnum


filename = "C:\Users\ashishkoul\Desktop\Pipe Delimit\sample.txt"' change file_path here
fnum = FreeFile()
Open filename For Output As fnum
Set rng = Range("a1:ah40000") ' Change range here
arr = rng

For j = LBound(arr) To UBound(arr)
    line = ""
    For i = 1 To rng.Columns.Count
        line = line & "|"& arr(j, i)
    Next
   
    Print #fnum, Right(line, Len(line) - 1)
Next

Close #fnum
End Sub

Viewing all articles
Browse latest Browse all 52

Trending Articles