Pages

Wednesday, July 14, 2010

VBA Code to Import data from notepad

Sub importnotepad()
On Error GoTo errhl
Dim notepadfile
notepadfile = Application.GetOpenFilename("Text Files (*.txt),*.txt", , "Please select text file...")
Workbooks.OpenText FileName:=notepadfile, Origin:=xlWindows, StartRow:=1
With ActiveWorkbook
ActiveSheet.Move After:=.Worksheets(.Worksheets.Count)
End With
errhl:
Exit Sub
End Sub

No comments:

Post a Comment