Xin chào! File excel của mình đang có khỏagg 55000 rows khi mình nhập tên khách hàng, ct sẽ tìm lần giao dịch trước của khách hàng dể lấy giá và công nợ, mình dùng range.find nhưng chương trình chạy chậm. giáo viên có thể tư vấn cho mình cách nào làm chương trình nhanh hơn dc kg ah
Chào bạn với file excel lớn như trên gitiho khuyên bản sử dụng vba để sử lý nhé.
minh dùng vba
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set wskt = Application.ThisWorkbook.Worksheets("KiemTraBanHang")
Dim r As Range
With wskt
If Target.Column = 4 Then
curRow = Target.row
Set r = wskt.Range(Cells(6, 3), Cells(curRow - 1, 3))
lastRow = .Cells(.Rows.Count, 1).End(xlUp).row 'tableKT.ListRows.Count + 5
khhang = wskt.Cells(curRow, 3).Value
If (khhang <> "Tông Tuyê'n" And khhang <> "Tông Ngày" And UCase(Trim(khhang)) <> "CHUABIET") Then
Cells(curRow, 3).Value = Application.WorksheetFunction.Proper(Cells(curRow, 3).Value)
preRow = LastItemLookup(khhang, r) + 5
If (preRow <> 5) Then
'Cells(preRow, 3).Select
Application.ScreenUpdating = False
'Application.EnableEvents = False
Cells(curRow, 6).Value = "=F" & preRow 'Cells(preRow, 6).Value
Cells(curRow, 10).Value = "=J" & preRow 'Cells(preRow, 10).Value
Cells(curRow, 14).Value = "=N" & preRow 'Cells(preRow, 14).Value
Cells(curRow, 18).Value = "=R" & preRow 'Cells(preRow, 18).Value
Cells(curRow, 22).Value = "=W" & preRow 'Cells(preRow, 22).Value
Cells(curRow, 26).Value = "=Z" & preRow 'Cells(preRow, 26).Value
Cells(curRow, 44).Value = "=AS" & preRow 'Cells(preRow, 45).Value
Cells(curRow, 40).Value = "=AO" & preRow 'Cells(preRow, 41).Value
Cells(curRow, 51).Value = "=BB" & preRow 'Cells(preRow, 54).Value
Application.ScreenUpdating = True
'Application.EnableEvents = True
End If
End If
End If 'If Target.Column = 4
End With
Application.OnKey "{F1}", "movetoSP"
Application.OnKey "{F2}", "movetoPV"
Application.OnKey "{F3}", "movetoV"
Application.OnKey "{F5}", "movetoHH"
Application.OnKey "{F6}", "movetoTT"
Application.OnKey "{F4}", "movetoB"
Application.OnKey "{F7}", "themKHcu"
Application.OnKey "{F11}", "tradungtien"
Application.OnKey "{F12}", "customersalecheck"
Application.OnKey "{F9}", "bangbanhang"
End Sub
mình thử dùng
Application.screenupdate = false,
Application.enableEvents = false
Application.Calculation = xlCalculationmanual
để bật tắt update .... nhưng vẫn chậm
Chào bạn bạn hãy tạo ra module sau đó trong sự kiện range khi thay đổi ở đâu thì call nó nhé.