TextToColumns Example : Excel to Text File « Excel « VBA / Excel / Access / Word






TextToColumns Example

 
Sub TestTextToColumns() 
    Dim rg As Range 
    Set rg = ThisWorkbook.Worksheets("Text to Columns").Range("a20").CurrentRegion 
    CSVTextToColumns rg, rg.Offset(15, 0) 
    CSVTextToColumns rg 
    Set rg = Nothing 
End Sub 
Sub CSVTextToColumns(rg As Range, Optional rgDestination As Range) 
    If IsMissing(rgDestination) Or rgDestination Is Nothing Then 
        rg.TextToColumns , xlDelimited, , , , , True 
    Else 
        rg.TextToColumns rgDestination, xlDelimited, , , , , True 
    End If 
End Sub 

 








Related examples in the same category

1.Exporting a range to a text file
2.Importing a text file to a range