|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
用好for each next比for next使用效果好。
- Private Sub deldeldel()
- Dim Rng As Range, Rng1 As Range, Rng2 As Range
- Dim oRng As Range
- Dim Str, Str1, Str2
- Dim Rr, Rr1
- Set Rng = Range(Cells(3, 2).Formula)
- Set Rng1 = Rng.Areas(1)
- Set Rng2 = Rng.Areas(2)
- For Each Rng1 In Rng.Areas(1)
- Rr = 1
- Debug.Print Rng1.Address, Rng1(2, 1).Address
-
- For Each Rng2 In Rng.Areas(2)
- 'Debug.Print Rng1, Rng2, Rng1 = Rng2
- Str = Application.WorksheetFunction.Ceiling(Rng2, 5 / 1440)
- If Round(Rng1, 5) = Round(Str, 5) Then
- If Rr = 1 Then
- Set oRng = Rng2
- Else
- Set oRng = Union(oRng, Rng2)
- End If
- 'Debug.Print Format(Rng1, "hh:mm"), Format(Str, "hh:mm"), Rng1.Address, Rng2.Address, oRng.Address
- Rr = Rr + 1
- End If
- Next Rng2
- If Not oRng Is Nothing Then
- Debug.Print oRng.Address
- Rng1(, 3) = "=" & oRng.Address(0, 0)
- Rng1(, 2) = oRng.Rows.Count
- oRng.Select
- End If
- Next Rng1
-
-
-
- End Sub
复制代码 |
|