Thầy cho em hỏi, em muốn tách dữ liệu trong 1 sheet thành nhiều file khác nhau, em chạy đoạn code sau, nhưng VBA báo lỗi "Run time error 13: Type Mismatch" ở dòng For Each xWs In ThisWorkbook.Sheets. Vậy em phải sửa như thế nào ạ?
Sub Splitbook()
Dim xPath As String
Dim testname As String
testname = InputBox("Phan chung cua ten file", "Enjoy Excel with Ms Quynh excel")
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim xWs As Range
For Each xWs In ThisWorkbook.Sheets
If xWs.Name <> "3844" And xWs.Name <> "Email_List" And xWs.Name <> "Settings" Then
xWs.Copy
Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & testname & "_" & xWs.Name & ".xlsx"
Application.ActiveWorkbook.Close False
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Done: check cac file trong folder chua file Master Split_send Email"
End Sub
Chào bạn bạn xem phần tách sheets như sau nhé
pass là gì thầy ơi