|
发表于 2016-7-15 21:47
|
显示全部楼层
本楼为最佳答案
cunfu2010 发表于 2016-7-15 20:27
传附件没成功,文字说明一下吧
就是当工作表中某天(单元格)为红色时,依据这个单元格,每隔12天,就有 ...
SHEET1:- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim i%, j%, t As Date, x%, b As Boolean
- If Target.Address <> "$A$1" Then Exit Sub
- If Target = "" Then Exit Sub
- t = CDate(Target.Value - 1 & "-12-31")
- j = 1
- Do
- j = j + 1
- For i = 1 To 10
- t = t + 1
- If Year(t) <> Target.Value Then Exit Sub
- Cells(j, i) = t
- If Cells(j, i).Interior.Color = 255 Then b = True
- If b = True Then x = x + 1
- If x <> 0 And x Mod 14 = 0 Then Cells(j, i).Interior.Color = 255
- Next
- Loop While Year(t) = Target.Value
- End Sub
复制代码 SHEET3:- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim i%, j%, t As Date, x%, b As Boolean
- If Target.Address <> "$A$1" Then Exit Sub
- If Target = "" Then Exit Sub
- t = CDate(Target.Value - 1 & "-12-31")
- j = 2
- Do
- For i = 1 To 10
- t = t + 1
- If Year(t) <> Target.Value Then Exit Sub
- Cells(j, i) = t
- Cells(j + 1, i) = Format(t, "aaaa")
- If Cells(j, i).Interior.Color = 255 Then b = True
- If b = True Then x = x + 1
- If x <> 0 And x Mod 14 = 0 Then Cells(j, i).Interior.Color = 255
- Next
- j = j + 3
- Loop While Year(t) = Target.Value
- End Sub
复制代码 SHEET2不知道怎么弄!下次提问的时候最好把需求一次性提完!
|
|