TEXT TO EXCEL | EXCEL VBA

Rate this post

BY THIS VBA ENABLED EXCEL SHEET YOU CAN TRANSFER TEXT FILE DIRECTLY IN EXCEL WITH THERE OWN COLUMNS

VBA Coding make our work very easy. Write one and use lifetime.
With this coding you can select your text file which you want to import in excel sheet.
It will divide texts to separate columns in excel. If you have rich text files, it is for you.
Just paste below simple coding in your excel sheet VBA modules and create a macro enabled button to import text to excel : 
Option Explicit
Sub ImportTextFile()
Dim vFileName

On Error GoTo ErrorHandle

‘WWW.LEARNWELLS.COM

vFileName = Application.GetOpenFilename(“Text Files (*.txt),*.txt”)


If vFileName = False Or Right(vFileName, 3) <> “txt” Then
   GoTo BeforeExit
End If


Application.ScreenUpdating = False


Workbooks.OpenText Filename:=vFileName, _
    Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
    xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, _
    Comma:=False, Space:=False, Other:=False, _
    TrailingMinusNumbers:=True, Local:=True


Columns(“A:A”).EntireColumn.AutoFit

BeforeExit:
Application.ScreenUpdating = True
Exit Sub
ErrorHandle:
MsgBox Err.Description
Resume BeforeExit
End Sub

It is very short code and very useful for your excel and also for your learning.
You can download the Excel sheet with VBA code with below download Link :


  
Tags: No tags

Add a Comment

Your email address will not be published. Required fields are marked *