Hi mọi người! mình là newbie
Mình muốn dùng VBA gộp nhiều file Excel thành 1 file duy nhất. Mình lên mạng tìm hiểu thì ra được đoạn code này:
code trên chạy ngon lành, gộp được tất cả các file trong thư mục "gopfile" thành 1 file.
Nhưng khi mình sửa lại đường dẫn "C:\Users\kei\Desktop\gopfile\" thành "C:\Users\kei\Desktop\gộp file\" hoặc tên file có chứa kí tự Tiếng Việt thì VBA báo lỗi vì không hiểu được kí tự Unicode.
Đây là dòng lỗi khi em run ạ:
"Run-time error '1004: Sorry, we couldn't find C:WUsersVPcVDesktoplfopfile\????-??????(1).xlsx. Is it possible it was moved, renamed or deleted?"
Có bác nào có giải pháp không ạ?
Mình muốn dùng VBA gộp nhiều file Excel thành 1 file duy nhất. Mình lên mạng tìm hiểu thì ra được đoạn code này:
Mã:
Sub GetSheets()
Dim path As String
Dim wb As Workbook
Dim sh As Worksheet
path = "C:\Users\kei\Desktop\gopfile\"
Filename = Dir(path & "*.xlsx")
Application.ScreenUpdating = False
Dim s As Integer
Do While Filename <> ""
Set wb = Workbooks.Open(Filename:=path & Filename, ReadOnly:=True)
For Each sh In wb.Sheets
s = s + 1
sh.Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Name = wb.Name & s
Next sh
wb.Close
Filename = Dir()
Loop
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
Nhưng khi mình sửa lại đường dẫn "C:\Users\kei\Desktop\gopfile\" thành "C:\Users\kei\Desktop\gộp file\" hoặc tên file có chứa kí tự Tiếng Việt thì VBA báo lỗi vì không hiểu được kí tự Unicode.
Đây là dòng lỗi khi em run ạ:
"Run-time error '1004: Sorry, we couldn't find C:WUsersVPcVDesktoplfopfile\????-??????(1).xlsx. Is it possible it was moved, renamed or deleted?"
Có bác nào có giải pháp không ạ?
Sửa lần cuối: