|
统计连续2次大于等于2的个数
- Sub 按钮1_Click()
- Dim c, r0, r, i, j
- r0 = 2 '数据源中第一个数据的行数
- c = Range("a2").End(xlToRight).Column
- Cells.Font.ColorIndex = 0
- For j = 1 To c Step 2 '遍历组
- r = Cells(r0, j).End(xlDown).Row - 1 '只需比较到倒数第2行
- For i = r0 To r
- If Cells(i, j) > 1 Then
- If Cells(i + 1, j) > 1 Then
- '满足统计1
- Cells(i, j).Font.ColorIndex = 3 '红
- Cells(i + 1, j).Font.ColorIndex = 3
- If Cells(i + 2, j + 1) > 10 Then
- '满足统计2
- Cells(i + 2, j + 1).Font.ColorIndex = 10 '绿
- End If
- i = i + 1 '规则不清,不好判断是否要这句,暂且使用。
- End If
- End If
- Next i
- Next j
- End Sub
复制代码
888b.rar
(10.11 KB, 下载次数: 22)
|
|