Lập trình VBA gộp dữ liệu từ nhiều file về một file Excel - Hàm JoinFiles của A-Tools
Bài giảng hướng dẫn chi tiết lập trình VBA để gộp file Excel hiển thị trạng thái gộp từng file rất chuyên nghiệp cùng với hàm API JoinFiles của Add-in A-Tools.
'------------------------------------------------------------------------------------------------------------
Sub TestJoinFiles()
Dim x, t1
t1 = getTickCount
x = JoinFiles(Range("C3").Value, Range("A4:A1003").Value, True, _
ObjPtr(ActiveCell), AddressOf DoProgress)
MsgBox "Thoi gian thuc hien: " & (getTickCount - t1) / 1000 & " giay" & vbNewLine & _
"So dong ghep duoc: " & x, vbInformation
End Sub
'------------------------------------------------------------------------------------------------------------
Sub DoProgress(ByVal Value As Long, ByVal MaxValue As Long, _
ByVal sSQL As String, ByVal sFile As String)
UserForm1.BSProgressBar1.Max = MaxValue
UserForm1.BSProgressBar1.Position = Value
UserForm1.Label1.Caption = Round(Value / MaxValue * 100, 0) & "%"
UserForm1.Label2.Caption = sSQL
UserForm1.Label3.Caption = sFile
DoEvents
End Sub