Ghép nhiều file txt vào excel (2 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

minhduong1289

Thành viên mới
Tham gia
10/4/12
Bài viết
1
Được thích
0
ACE nào giúp em với, e có nhiều file txt muốn tổng hợp thành 1 excel thì làm như thế nào. dữ liệu truyền về khoản 5phut lần. Em muốn tổng hợp lại thành 1 file excel để làm báo cáo ngày .
 

File đính kèm

ACE nào giúp em với, e có nhiều file txt muốn tổng hợp thành 1 excel thì làm như thế nào. dữ liệu truyền về khoản 5phut lần. Em muốn tổng hợp lại thành 1 file excel để làm báo cáo ngày .
Trong khi chờ đợi người khác giúp, bạn thử chạy code sau:

Mã:
Sub test()
    Dim strFileName As Variant
    Dim i As Integer
    strFileName = Application.GetOpenFilename("Text Files (*.txt), *.txt", _
                  Title:="Select files", MultiSelect:=True)
    Application.ScreenUpdating = False
    If IsArray(strFileName) Then
        For i = LBound(strFileName) To UBound(strFileName)
            With Sheet1.QueryTables.Add(Connection:= _
                "TEXT;" & strFileName(i), Destination:=Sheet1.Range("A" & Sheet1.Range("A65000").End(xlUp).Row + 1))
                .TextFilePlatform = 65001
                .Refresh
            End With
        Next i
    End If
    Sheet1.Cells.ColumnWidth = 9
    Application.ScreenUpdating = True
End Sub
 

File đính kèm

nếu muốn lấy cả tên của file txt đó vào trong excel để phân biệt thì thế nào hả bác?
 
Web KT

Bài viết mới nhất

Back
Top Bottom