|
本帖最后由 renlong 于 2016-9-12 18:54 编辑
想通过VBA的方式快速把F列的标注出是否存在重复值和不重复值,我是手动填的,
判别条件:
在D列数据中,先判断是不是一组,是一组的话再看后面E列,如果D2:D22这个区域中,a_291这一组数据对应的后面E列值去看,如果E2:E22这个区域中的任何一个值和其他剩余的E2:E22中的值都不一样的话,那么F2:F22写存在不重复值;如果E2:E22区域里的值都一样(即这21个值都是一样的,而不是有几个是一样的),那么后面就写存在重复值,
截图2
祝您好运!
请测试: - Sub wanao()
- Dim x As Integer, endL As Integer, sRow As Integer
- Dim Str1 As String, str2 As String
- Dim cF As Boolean
- endL = Cells(Rows.Count, "d").End(xlUp).Row
- For x = 2 To endL
- If Str1 = "" Or Str1 <> Cells(x, "d") Then
- Str1 = Cells(x, "d")
- str2 = Cells(x, "e")
- sRow = x
- cF = False
- Else
- If Cells(x, "e") <> str2 Then cF = True
- If cF Then Range(Cells(sRow, "f"), Cells(x, "f")) = "存在不重复值" Else Range(Cells(sRow, "f"), Cells(x, "f")) = "不存在"
- End If
- Next
- End Sub
复制代码
|
|