KIỂM TRA ĐỐI CHIẾU 2 FILE EXCEL

ngocyen

Yêu THVBA
Hi Anh Chị

nhờ anh chị xem giúp em code này có vấn đề gì không mà em khởi tạo rồi chạy nhưng không hiện lên lỗi hay thành công gì cả.

không biết do lỗi hay do em thao tác không đúng nhờ anh chị chỉ giúp em.

ý nghĩa code này là check thông tin từ file CONGNO và SHIPMENT xem có đúng không và bôi màu ở những điểm không đúng.

"""
Sub DoiChieuCongNoTrenNhieuSheet()
Dim wsShipment As Worksheet
Dim wsCongNo As Worksheet
Dim lastRowShipment As Long
Dim lastRowCongNo As Long
Dim i As Long, j As Long

For Each sheetName In Array("SEA-IM-FCL DP")

On Error Resume Next
Set wsShipment = ThisWorkbook.Sheets(sheetName)
On Error GoTo 0

If Not wsShipment Is Nothing Then
lastRowShipment = wsShipment.Cells(wsShipment.Rows.Count, "A").End(xlUp).Row

If lastRowShipment = 0 Then lastRowShipment = 1

For i = 2 To lastRowShipment
For Each wsCongNo In ThisWorkbook.Sheets
If InStr(1, wsCongNo.Name, "CongNoVendor") > 0 Then
lastRowCongNo = wsCongNo.Cells(wsCongNo.Rows.Count, "A").End(xlUp).Row

If lastRowCongNo = 0 Then lastRowCongNo = 1

For j = 2 To lastRowCongNo
If wsShipment.Cells(i, "INVOICE").Value = wsCongNo.Cells(j, "INV NO").Value And _
wsShipment.Cells(i, "BILL OF LADING").Value = wsCongNo.Cells(j, "B/L NO").Value And _
wsShipment.Cells(i, "TYPE OF TRUCK").Value = wsCongNo.Cells(j, "TRANSPORTATION").Value And _
wsShipment.Cells(i, "VOLUME").Value = wsCongNo.Cells(j, "VOLUME").Value And _
wsShipment.Cells(i, "CDs").Value = wsCongNo.Cells(j, "CDS NO").Value Then
wsShipment.Range(wsShipment.Cells(i, "B"), wsShipment.Cells(i, "F")).Interior.Color = RGB(255, 0, 0)
wsCongNo.Range(wsCongNo.Cells(j, "A"), wsCongNo.Cells(j, "E")).Interior.Color = RGB(255, 0, 0)
End If
Next j
End If
Next wsCongNo
Next i
End If
Next sheetName
End Sub
 
Bạn có thể kéo links file về đây được không? chỉ nhìn code không thấy dữ liệu nên không hiểu lắm
 

ngocyen

Yêu THVBA
Bạn có thể kéo links file về đây được không? chỉ nhìn code không thấy dữ liệu nên không hiểu lắm
Dạ em gửi link của 2 file ạ.

shipment:
congno:
 
Top