|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim arr()
- Dim lastRow%
- Dim myColor As Long
-
- lastRow = [a1].End(xlDown).Row
- arr = [a1].Resize(lastRow, 8).Value
-
- n = 0
- For i = 2 To lastRow - 1 '获取参照行
- For j = i + 1 To lastRow '获取比较行
- n = 0 '开始一个新的比较行,计数器就清零
- For ii = 3 To 8 '获取参照行参照单元格
- For jj = 3 To 8 '获取比较行比较单元格
- If arr(j, jj) = arr(i, ii) Then
- n = n + 1 '计数器用来统计重复单元格的个数
- End If
- If n = 4 Then
- myColor = Int(Rnd * &HFFFFFF) Or &H707070
- Rows(i).Cells.Interior.Color = myColor
- Rows(j).Cells.Interior.Color = myColor
- Cells(j, 9).Value = "与" & Cells(i, 2).Value & "重复4个报价"
- Cells(j, 10).Value = "序号数相差" & j - i
- End If
- Next
- Next
- Next
- Next
- End Sub
复制代码 |
|