Kiểm tra và thoát kiểm tra dữ liệu trùng (1 người xem)

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

Tran Mui

Thành viên thường trực
Tham gia
29/12/07
Bài viết
237
Được thích
56
Tôi có một danh sách , cần GPE giúp cách làm khi nhấn nút kiểm tra sẽ thông báo được ô dữ liệu trùng nhau và tô màu, sau khi xong nhấn nút thoát sẽ trở lại bình thường. File và yêu cầu đính kèm
Mong mọi người giúp
 

File đính kèm

2 macro của bạn đây & những mong khỏi đưa file lên.

PHP:
Private Sub CommandButton1_Click()
 Dim Rng As Range, sRng As Range, Cls As Range
 Dim eRw As Long, MyAdd As String
 
 Columns("B:D").Interior.ColorIndex = 2
 eRw = [B65500].End(xlUp).Row
 Set Rng = Range("B5:B" & eRw)
 For Each Cls In Rng(2).Resize(eRw - 1)
   Set sRng = Rng.Find(Cls.Value, , xlFormulas, xlWhole)
   If Not sRng Is Nothing Then
      MyAdd = sRng.Address
      Do
         If MyAdd <> sRng.Address Then
            sRng.Resize(, 3).Interior.ColorIndex = 38
            Range(MyAdd).Resize(, 3).Interior.ColorIndex = 42
         End If
         Set sRng = Rng.FindNext(sRng)
      Loop While Not sRng Is Nothing And MyAdd <> sRng.Address      
   End If
 Next Cls
End Sub
PHP:
Private Sub CommandButton2_Click()
   Columns("B:D").Interior.ColorIndex = 2
End Sub
 
Upvote 0
Bạn thử kiểu này xem, muốn kiểm tra nhấn đánh dấu ô chọn

Mã:
Sub Condad()
Dim ch As String
 With Range(Sheet1.[B6], Sheet1.[B65536].End(3)).Resize(, 3)
   .FormatConditions.Delete
     If Sheet1.[E3] = True Then
      .FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=COUNTIF(R6C2:R" & .Rows.Count & "C2,RC2)>1"
      .FormatConditions(1).Interior.ColorIndex = 7
    End If
  End With
End Sub
 

File đính kèm

Upvote 0

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

Back
Top Bottom