【发布时间】:2011-07-01 09:07:40
【问题描述】:
我正在根据用户表单中的条目生成 Excel 工作表。一个条目是项目持续时间的报告间隔。假设报告间隔为 3 个月,Phase2 的持续时间为 10 个月,Phase3 的持续时间为 3 个月。
我的列的结构是这样的,相位之间有一个单元格的距离:
Phase1: Starting phase
Phase2: Working phase
Phase3: Closing phase
Phase1 Phase2 Phase3
|||||| ||||||||||||||||||||||||||| ||||||
报告间隔应标记为 Phase2 和 Phase3 中的彩色单元格,如下所示:
Phase1 Phase2 Phase3
|||||| |||||||O|||||||||||O|||||||| ||O||||
这是我为单元格着色的代码:
For x = 1 To (Implementationduration + Closingduration - 1) / 3
Select Case x
Case Is < Implementationduration:
Call SetFontAndBackground(cells(Rowindex, Phase1CellLast() + Columncounter * 3), cells(Rowindex, Phase1CellLast() + Columncounter * 3), False, False, "", 10, False, "b", "lcyan", False)
Columncounter = Columncounter + 4
Case Is > Implementationduration:
Call SetFontAndBackground(cells(Rowindex, Phase1CellLast() + Columncounter * 3 + 1), cells(Rowindex, Phase1CellLast() + Columncounter * 3 + 1), False, False, "", 10, False, "b", "lcyan", False)
Columncounter = Columncounter + 4
End Select
Next x
问题是 Phase3 中的彩色单元格没有正确定位。他们离开了一个牢房。对于着色,我使用一个子程序来格式化单元格。我在我的代码中找不到错误。
【问题讨论】: