Trong file có đó bạn, đoạn code như sau:
Sub taods()
Dim i As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
i = 5
With ThisWorkbook.Sheets("Data")
While (.Cells(i, 3) <> "")
ThisWorkbook.Sheets("Form").Cells(3, 5) = .Cells(i, 3)
ThisWorkbook.Sheets("Form").Copy
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\Danh Sach\" & .Cells(i, 3) & "_" & .Cells(i, 4) & ".xlsx", Password:=.Cells(i, 13)
ActiveWorkbook.Close
i = i + 1
Wend
End With
MsgBox "!!!Hoan Thanh!!!"
Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub
Tôi chép code trong file ra cho bạn thấy. Bạn tải về xem lại file đi, xem tôi có nói sai không?
Sub taods()
Dim i As Integer
'Bo qua canh bao va nhap nhay khi chay chuong trinh
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'Gán gia tri dau tien
i = 5
'Quét tung nhan vien 1
With ThisWorkbook.Sheets("Data")
While (.Cells(i, 3) <> "")
'Gán ma cho tung nhan vien
ThisWorkbook.Sheets("Form").Cells(3, 5) = .Cells(i, 3)
'Trich xuat shhet Form ra file moi
ThisWorkbook.Sheets("Form").Copy
'Luu file sau khi xuat vao folder danh sach va dat pass
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\Danh Sach\" & .Cells(i, 3) & "_" & .Cells(i, 4) & ".xlsx", Password:=.Cells(i, 13)
ActiveWorkbook.Close
i = i + 1
Wend
End With
'Hien thong bao ket thuc chuong trinh
MsgBox "!!!Hoan Thanh!!!"
Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub