Nhờ hiệu chỉnh code ngan gon dễ dùng (1 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

HUYNHTIEN0202

Thành viên chính thức
Tham gia
22/8/14
Bài viết
92
Được thích
1
Nội dung file như sau
Cột G & H so sánh với cột AE & AF nếu khac nhau thi tô màu cột H
code đang dùng
Mã:
Dim Arr(1 To 2000, 1 To 3) As Variant
Dim dArr(1 To 2000, 1 To 3) As Variant
Dim I As Integer, J As Integer, K As Integer
Dim checkrow As Integer, Rw As Long
With Sheet6
.Range([B6], .[B6].End(xlDown)).Resize(, 23).Interior.ColorIndex = 0
'------------------------------------------------------------------------
'Arr = .Range([G6], .[G6].End(xlDown)).Resize(, 3)
'dArr = .Range([AE6], .[AE6].End(xlDown)).Resize(, 3)
Do
Rw = Rw + 1
 Arr(Rw, 1) = .Cells(Rw + 6, 7)
 Arr(Rw, 2) = .Cells(Rw + 6, 8)
Loop Until .Cells(Rw + 6, 7) = ""


'-------------------------------------------------------------------------
For I = 1 To 2000
    checkrow = checkrow + 1
    dArr(checkrow, 1) = .Cells(I + 6, 31)
    dArr(checkrow, 2) = .Cells(I + 6, 32)
Next
'-----------------------------------------------------------------------------
 For I = 1 To checkrow
   For J = 1 To Rw
       If Arr(J, 1) = dArr(I, 1) Then
        If Arr(J, 2) <> dArr(I, 2) Then
         For K = 1 To 2000
             If .Cells(K, 7) = Arr(J, 1) Then
                .Cells(K, 8).Interior.ColorIndex = 6
            End If
            Next K
        End If
          Exit For
      End If
   Next J
 Next I
 End With
 MsgBox ("FINISH")
 

File đính kèm

Trong khổ lệnh:

PHP:
    For I = 1 To 2000
        checkRow = checkRow + 1
        dArr(checkRow, 1) = .Cells(I + 6, 31)
        dArr(checkRow, 2) = .Cells(I + 6, 32)
    Next
Bạn có thể cụ thể hóa con số 2000 này thành 1 con số thực trong dữ liệu cột thứ 31 của bạn, như:

(Dim Rws a long)
Rws= .Cells(6,31).CurrentRegion.Rows.Count
For I = 6 to Rws
' . . . . '
Next
 
Upvote 0
Web KT

Bài viết mới nhất

Back
Top Bottom