|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Dim flg As Boolean
- Set d = CreateObject("scripting.dictionary")
- flg = True
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:c" & r)
- ReDim brr(1 To UBound(arr), 1 To 1)
- For i = UBound(arr) To 1 Step -1
- If IsNumeric(arr(i, 1)) And arr(i, 1) >= 1 And arr(i, 1) <= 31 Then
- rq = CDate("2017-7-" & arr(i, 1))
- If flg Then
- rq0 = rq
- flg = False
- End If
- Else
- brr(i, 1) = rq
- End If
- Next
- For i = UBound(arr) To 1 Step -1
- If IsNumeric(arr(i, 1)) And arr(i, 1) >= 1 And arr(i, 1) <= 31 Then
- Exit For
- End If
- brr(i, 1) = rq0 + 1
- Next
- .Range("i2").Resize(UBound(brr), 1) = brr
- .Range("j2").Resize(UBound(arr), UBound(arr, 2)) = arr
- For i = 1 To UBound(arr)
- If Not d.exists(brr(i, 1)) Then
- Set d(brr(i, 1)) = CreateObject("scripting.dictionary")
- End If
- If Not d(brr(i, 1)).exists(arr(i, 1)) Then
- d(brr(i, 1))(arr(i, 1)) = i
- Else
- m = d(brr(i, 1))(arr(i, 1))
- .Cells(m + 1, 9).Resize(1, 4).Interior.ColorIndex = 6
- .Cells(i + 1, 9).Resize(1, 4).Interior.ColorIndex = 6
- End If
- Next
-
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|