Lê Việt
Lê Việt
Thảo luận 4 thảo luận
Vỗ tay 0 vỗ tay
Lượt xem 209 lượt xem

File excel của mình đang có khỏagg 55000 rows khi mình nhập tên khách hàng ct

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



Thảo luận 4 câu trả lời
Lượt xem 209 lượt xem
Vỗ tay vỗ tay
Lê Việt 17:08 - Aug 20, 2021

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é.

Vỗ tay vỗ tay
Lê Việt 17:08 - Aug 20, 2021

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

Vỗ tay vỗ tay
Lê Việt 17:08 - Aug 20, 2021

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

Vỗ tay vỗ tay
Lê Việt 10:08 - Aug 21, 2021

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é.

Vỗ tay vỗ tay
Câu hỏi liên quan
© 2020 - Bản quyền của Công Ty Cổ Phần Công Nghệ Giáo Dục Gitiho Việt Nam
Giấy chứng nhận Đăng ký doanh nghiệp số: 0109077145, cấp bởi Sở Kế hoạch và Đầu tư TP. Hà Nội
Giấy phép mạng xã hội số: 588, cấp bởi Bộ Thông tin và Truyền thông