Minggu, 12 Juli 2015

Copy file txt to Workbook Excel

01.11

Berikut ini adalah cara untuk mengkopi file txt ke dalam workbook yang aktif:
File txt contoh berada di dalam direktori : "D:\Bisa\YC\YC PEMI052015\\MAY-15.txt"
Copy paste kode ini di modul excel.

Dim DestBook As Workbook, SourceBook As Workbook
Dim DestCell As Range
Dim RetVal As Boolean
Dim sFName As String
' Turn off screen updating.
Application.ScreenUpdating = False
Set DestBook = ActiveWorkbook
Set DestCell = Range("A1")
Workbooks.OpenText FileName:="D:\Bisa\YC\YC PEMI052015\\MAY-15.txt"
Set SourceBook = ActiveWorkbook
'Copy the contents of the entire sheet containing the text file.
Range(Range("A1"), Range("A1").SpecialCells(xlLastCell)).Copy
DestBook.Activate
DestCell.PasteSpecial Paste:=xlValues
Columns("A:Z").EntireColumn.AutoFit
'Close the book containing the text file.
SourceBook.Close False
End Sub
      

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 komentar:

Posting Komentar

 

© 2013 Amanah Fitri. All rights resevered. Designed by Templateism

Back To Top