|
楼主 |
发表于 2024-3-19 07:23
|
显示全部楼层
- Sub ll()
- Dim ii, Kk
- Dim Rng1 As Range, Rng2 As Range
- Set Rng1 = Cells(15, "A").CurrentRegion
- Set Rng2 = Cells(15, "H").CurrentRegion
- Rng2.Interior.Color = xlNone
- Rng1.Interior.Color = xlNone
- Debug.Print Rng1.Address, Rng2.Address
-
- Dim oDate As Date, oDate1 As Date, oDate2 As Date
- For ii = 1 To Rng2.Rows.Count
- oDate = Rng2(ii, 1)
- For Kk = 1 To Rng1.Rows.Count - 1
- oDate1 = Rng1(Kk, 1)
- oDate2 = Rng1(Kk + 1, 1)
- If oDate >= oDate1 And oDate < oDate2 Then
- Rng1(Kk, 3) = "=" & Rng2(ii, 2).Address
- Rng1(Kk, 4) = "=" & Rng2(ii, 1).Address
- Rng2(ii, 2).Interior.ColorIndex = Kk
- Rng1(Kk, 3).Interior.ColorIndex = Kk
- End If
- Next Kk
- Next ii
-
- End Sub
复制代码
|
|