本帖最后由 安全网 于 2016-4-14 22:13 编辑
Private Sub Worksheet_Change(ByVal Target As Range)
Dim arr, j
If Target.Count > 1 Then Exit Sub
w = Target.Row: c = Target.Column: x = Target.Value
Dim RN As Range
r = ""
If (c > 2 And c < 6) Or c = 8 Then
xstr = Cells(w, 3) & Cells(w, 4) & Cells(w, 5) & Cells(w, 8)
If Len(x) > 0 Then
arr = Range("C1:H" & Range("C65536").End(3).Row)
For i = 3 To UBound(arr)
If w <> i And arr(i, 1) & arr(i, 2) & arr(i, 3) & arr(i, 6) = xstr Then
r = r & "," & i
If RN Is Nothing Then Set RN = Range("C" & i & ":H" & i) Else Set RN = Union(RN, Range("C" & i & ":H" & i))
End If
Next
If r <> "" Then
RN.Borders.Weight = xlMedium
RN.Interior.ColorIndex = 6
If MsgBox("当前输入数据与第 " & Mid(r, 2) & " 行相同!是否需要删除?", 4 + 32 + 256) = 6 Then
Application.EnableEvents = False
Rows(w).ClearContents
RN.Interior.ColorIndex = 0
RN.Borders.Weight = xlThin
Application.EnableEvents = True
End If
End If
End If
End If
End Sub
Cells(w, 3) & Cells(w, 4) & Cells(w, 5) & Cells(w, 8)这个怎么样设置这4个单元格非空才显示,只要其中一个单元格没有值就不提示
|