Mình không hiểu lỗi này "Unable to set the LineStyle property of the Border class" có nghĩa là gì mà cứ bị hoài khi chạy đoạn code phía dưới.
Và còn 1 lỗi nữa là khi chạy code nếu không tìm thấy file thì nó báo lỗi thế này "The Microsoft Jet Database engine could not find the object 'link file'. Make sure the object exits and that you spell its name and the path name correctly" . Có cách nào để không hiển thị thông báo lỗi như thế này mà sẽ hiển thị thông báo là "Không tìm thấy file này trong thư mục" được không vậy?
Nhờ các anh chị giúp đỡ, em xin chân thành cảm ơn nhiều
Và còn 1 lỗi nữa là khi chạy code nếu không tìm thấy file thì nó báo lỗi thế này "The Microsoft Jet Database engine could not find the object 'link file'. Make sure the object exits and that you spell its name and the path name correctly" . Có cách nào để không hiển thị thông báo lỗi như thế này mà sẽ hiển thị thông báo là "Không tìm thấy file này trong thư mục" được không vậy?
Nhờ các anh chị giúp đỡ, em xin chân thành cảm ơn nhiều

Sub doichieu() Application.ScreenUpdating = False
Range("J9" & Range("J1000").End(3).Row + 1).ClearContents
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ThisWorkbook.Path & "\DATA.xls;Extended Properties=""Excel 8.0;HDR=NO;IMEX=1"";"
Range("J9").CopyFromRecordset cn.Execute("SELECT f1,f12,f13,f31*1000,f40*1000,(f49+f59+f66)*1000,f91*1000 FROM [THA$A6:CM1000] where f1 >0")
Range("J9:J" & Range("J1000").End(3).Row).Value = "=row()-8"
Range("J9" & Range("J1000").End(3).Row).Borders.LineStyle = xlContinuous
Range("J91000").Select
Selection.Sort Key1:=Range("L6"), Order1:=xlAscending, Key2:=Range("K6") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End Sub
File đính kèm
Lần chỉnh sửa cuối: