如何制作項目進度計劃表 項目進度表模板( 二 )

數組代碼
【如何制作項目進度計劃表 項目進度表模板】Private Sub getXarr()    xArr = Array(序號, 部門, 類別, 項目名稱, _                 計劃開始時間, 計劃結束時間, 實際開始時間, 實際結束時間, 時長)End Sub添加項目過程代碼(AddSheetRange())
Private Sub AddSheetRange(uArr)Dim s As Worksheet, cell As Range, ic As Integer, ix As IntegerDim st1 As Integer, st2 As Integer, xt1 As Integer, xt2 As IntegerSet s = ActiveSheetSet cell = s.Range(B4:AN5)cell.Insert shift:=xlDownWith cell    .ClearFormats    With .Font        .Size = 10        .Name = 仿宋    End With    For ic = 1 To 4         cell.Cells(1, ic).Value = uArr(ic - 1)         s.Range(cell.Cells(1, ic), cell.Cells(2, ic)).Merge    Next ic     .Interior.Color = RGB(239, 239, 239)    .Borders.LineStyle = 3    .Borders.Color = RGB(112, 121, 211)    cell.Cells(1, 5).Value = 計劃    cell.Cells(2, 5).Value = 實際    cell.Cells(1, 6).Value = uArr(4) '計劃開始時間    cell.Cells(1, 7).Value = uArr(5) '計劃結束時間    cell.Cells(2, 6).Value = uArr(6) '實際開始時間    cell.Cells(2, 7).Value = uArr(7) '實際結束時間    cell.Cells(1, 8).Value = =H4-G4 'VBA.DateDiff(d, uArr(4), uArr(5)) '計劃時長    cell.Cells(2, 8).Value = =H5-G5 'VBA.DateDiff(d, uArr(6), uArr(7)) '實際時長    st1 = VBA.Day(uArr(4)) + 8    st2 = VBA.Day(uArr(5)) + 8    xt1 = VBA.Day(uArr(6)) + 8    xt2 = VBA.Day(uArr(7)) + 8    s.Range(cell.Cells(1, st1), cell.Cells(1, st2)).Style = S1    s.Range(cell.Cells(2, xt1), cell.Cells(2, xt2)).Style = S2    ix = Application.WorksheetFunction.CountA(s.Range(B:B)) - 2End WithEnd Sub甘特圖形的繪制是對表格樣式的一個賦值,本示例中樣式名為S1和S2 。
一代碼是對樣式進行設置的,有判斷樣式是否存在、添加等一些操作 。
歡迎關注、收藏

推薦閱讀