Beruflich Dokumente
Kultur Dokumente
'The copyright and intellectual property rights of this template and VBA Procedures and Functions a
re owned by Gantt Excel (www.GanttExcel.com), United States,
'and are protected by copyright laws and international intellectual property right treaties.
'You may not copy any portion of the template or vba code in any form, except to use this template
in accordance with the terms of the agreement or
'to make one copy for backup purposes. You may not alter the software in any way.
Option Explicit
Dim bDontDelete As Boolean
Dim bfDiasabledEvents As Boolean
Private Sub btnAddDependency_Click()
Me.cmbTaskName.ListIndex = -1
Me.cmbDependencyType.ListIndex = -1
Me.txtDelay.Value = vbNullString
End Sub
Me.txtDelay = Me.lstDependencies.List(Me.lstDependencies.ListIndex, 3)
frm_Task - 2
btnEditDependency.Caption = "Save"
ElseIf btnEditDependency.Caption = "Save" Then
With Me.lstDependencies
.enabled = True
.List(.ListIndex, 2) = Me.cmbDependencyType
.List(.ListIndex, 3) = Me.txtDelay
End With
With Me.cmbTaskName
.enabled = True
.Style = fmStyleDropDownList
End With
Me.cmbDependencyType = vbNullString
Me.txtDelay = vbNullString
btnEditDependency.Caption = "Edit"
Me.btnAddDependency.enabled = True
Me.btnDeleteDependency.enabled = True
Me.btnClearDependencyInputs.enabled = True
Me.lstDependencies.ListIndex = -1
lstDependencies_Click
End If
End Sub
Me.cmbResource.Value = sResourcesNamesFromForm
sResourcesNamesFromForm = vbNullString
bAddResourceValueToFormNotToCell = False
End Sub
Sub PopulateEstimatesCostsFromResource()
If Me.cmbResource <> vbNullString Then
If Me.txtCalendarDays.Value = vbNullString Then
Me.txtResourceCost.Value = GetResourcesTotalCost(cmbResource.Text)
Else
Me.txtResourceCost.Value = GetResourcesTotalCost(cmbResource.Text, Me.txtCalendarDays)
End If
End If
End Sub
bfDiasabledEvents = True
Dim sTmp As String, I As Long
Me.lblCalculatingDependencies.visible = False
If bAddTask Or bAddMilestone Then InsertNewRow
Me.txtDelay.enabled = False
Me.lstDependencies.enabled = False
Me.btnAddDependency.enabled = False
Me.btnEditDependency.enabled = False
Me.btnDeleteDependency.enabled = False
Me.btnClearDependencyInputs.enabled = False
Me.cmbTaskName.BackColor = Me.BackColor
Me.cmbDependencyType.BackColor = Me.BackColor
Me.txtDelay.BackColor = Me.BackColor
Me.lstDependencies.BackColor = Me.BackColor
Me.cmbPercentageCompleted.Value = 0
EnableDisableCosts
End Sub
End With
EnableDisableCosts
If Cells(cRowPos, colPos.CostsModule).Value = 1 Then
Me.txtACS = Cells(clRow, colPos.ACS).Value
Me.txtECS = Cells(clRow, colPos.ECS).Value
Me.txtBCS = Cells(clRow, colPos.BCS).Value
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.EED Then
With Me.txtEndDate
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.PercentageCompleted Then
With Me.cmbPercentageCompleted
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.ED Then
With Me.txtCalendarDays
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.BSD Then
With Me.txtBSD
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.ASD Then
With Me.txtASD
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.AED Then
With Me.txtAED
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.BED Then
With Me.txtBED
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.BD Then
With Me.txtBD
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.ECS And Cells(cRowPos, colPos.EnableCostsModule) Then
With Me.txtECS
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.ACS And Cells(cRowPos, colPos.EnableCostsModule) Then
With Me.txtACS
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.BCS And Cells(cRowPos, colPos.EnableCostsModule) Then
With Me.txtBCS
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf dblClickCol = colPos.Notes Then
With Me.txtNotes
.SetFocus
End With
End If
End If
End Sub
Private Sub txtASD_Enter()
bTriggerFromTaskFormCalendar = True
frm_Task - 7
btnOk_AddEditTask
UpdateDependenciesToSheetFromForm
Last:
bDontDelete = True
Unload Me
AddRollingText
'Calcualte only added task has dependency added or removed. If having cost then only update cos
ts
If bAddTask = True Or bAddMilestone = True Then
If lstDependencies.ListCount > 0 Then
PopulateSectionDates , clRow
ElseIf Me.txtBCS <> vbNullString Or Me.txtECS <> vbNullString Or Me.txtACS <> vbNullString
Then
ReCalculateBudgetLineCosts
End If
Else
If Cells(clRow, colPos.tDependents).Value = vbNullString Then
PopulateSectionDates , clRow
Else
PopulateSectionDates
End If
End If
ReBuildView
AddGanttBarsForEachRow
LockSheet ActiveSheet
EnableAll
End Sub
Rows(clRow).Font.Color = RGB(0, 0, 0)
Cells(clRow, colPos.BSD).HorizontalAlignment = xlRight
Cells(clRow, colPos.BED).HorizontalAlignment = xlRight
Cells(clRow, colPos.BD).HorizontalAlignment = xlRight
If Me.chkMilestone Then
Cells(clRow, colPos.TColor).Interior.Color = Cells(cRowPos, colPos.MColor).Value
Cells(clRow, colPos.TPColor).Interior.Color = Cells(cRowPos, colPos.MColor).Value
Else
Cells(clRow, colPos.TColor).Interior.Color = Cells(cRowPos, colPos.EstimatedTimelineCol
or).Value
Cells(clRow, colPos.TPColor).Interior.Color = Cells(cRowPos, colPos.PercentageColor).Va
lue
End If
If Me.chkMilestone Then
Cells(clRow, colPos.tType).Value = "M"
Else
Cells(clRow, colPos.tType).Value = "T"
End If
Cells(clRow, colPos.Task).Value = Me.txtTask.Value
Cells(clRow, colPos.TaskLead).Value = Me.cmbResource.Value
Me.txtBSD.Value = Me.txtStartDate
Me.txtBED.Value = Me.txtEndDate
Me.txtBD.Value = Me.txtCalendarDays
Application.EnableEvents = True
End Sub
Private Sub frmEstimated_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtCalendarDays_ExitCalculation
End Sub
Private Sub cmbPercentageCompleted_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii >= 48 And KeyAscii <= 57 Then
Else
KeyAscii = 0
End If
End Sub
Private Sub txtCalendarDays_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii >= 48 And KeyAscii <= 57 Then
Else
KeyAscii = 0
End If
End Sub
Private Sub txtBD_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii >= 48 And KeyAscii <= 57 Then
Else
KeyAscii = 0
End If
End Sub
Private Sub txtECS_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii >= 48 And KeyAscii <= 57 Then
Else
KeyAscii = 0
End If
End Sub
Private Sub txtBCS_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii >= 48 And KeyAscii <= 57 Then
Else
KeyAscii = 0
End If
End Sub
Private Sub txtACS_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii >= 48 And KeyAscii <= 57 Then
Else
KeyAscii = 0
End If
End Sub
Private Sub txtStartDate_Enter()
bTriggerFromTaskFormCalendar = True
If txtStartDate.Value = vbNullString Then
dFormDate = Date
Else
dFormDate = CDate(txtStartDate.Value)
End If
frmDateSelector.Show
If bNoDateSelectedForForm = False Then
txtStartDate.Value = Format(dFormDate, "DD-MMM-YYYY")
End If
Me.btnOk.SetFocus
txtStartDate_ExitCalculation
bTriggerFromTaskFormCalendar = False
bNoDateSelectedForForm = False
End Sub
Private Sub txtStartDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtStartDate_ExitCalculation
End Sub
Private Sub txtStartDate_ExitCalculation()
Dim tdate As Date
If IsDate(txtStartDate.Value) = False Then
txtStartDate.Value = vbNullString
GoTo Last
ElseIf txtStartDate.Value < csDate Or txtStartDate.Value > ceDate Then
ShowOutofDatesMessage
txtStartDate.Value = vbNullString
txtStartDate.SetFocus
GoTo Last
Else
txtStartDate.Value = Format(txtStartDate.Value, "DD-MMM-YYYY")
End If
frm_Task - 12
Else
txtCalendarDays.Value = GetWorkDaysFromDate(CDate(txtStartDate.Value), CDate(txtEndDate
.Value))
End If
GoTo Last
End If
Last:
PopulateEstimatesCostsFromResource
End Sub
Private Sub txtCalendarDays_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtCalendarDays_ExitCalculation
End Sub
Private Sub txtCalendarDays_ExitCalculation()
Dim wd As Long, tdate As Date
If txtCalendarDays.Value = vbNullString Or txtCalendarDays.Value = 0 Then
txtCalendarDays.Value = 1
End If
If IsDate(txtStartDate.Value) And IsDate(txtEndDate.Value) Then
wd = GetWorkDaysFromDate(CDate(txtStartDate.Value), CDate(txtEndDate.Value))
If wd <> txtCalendarDays.Value Then
tdate = Format(GetEndDateFromWorkDays(CDate(txtStartDate.Value), txtCalendarDays.Value)
, "DD-mmm-yyyy")
If tdate < csDate Or tdate > ceDate Then
ShowOutofDatesMessage
txtEndDate.Value = vbNullString
Else
txtEndDate.Value = Format(tdate, "DD-mmm-YYYY")
End If
End If
GoTo Last
ElseIf IsDate(txtStartDate.Value) And txtEndDate.Value = vbNullString Then
tdate = Format(GetEndDateFromWorkDays(CDate(txtStartDate.Value), txtCalendarDays.Value), "D
D-mmm-YYYY")
If tdate < csDate Or tdate > ceDate Then
ShowOutofDatesMessage
txtEndDate.Value = vbNullString
Else
txtEndDate.Value = Format(tdate, "DD-mmm-YYYY")
End If
ElseIf txtStartDate.Value = vbNullString And IsDate(txtEndDate.Value) Then
tdate = Format(GetStartFromWorkDays(CDate(txtEndDate.Value), txtCalendarDays.Value), "DD-mm
m-YYYY")
If tdate < csDate Or tdate > ceDate Then
ShowOutofDatesMessage
txtStartDate.Value = vbNullString
Else
txtStartDate.Value = Format(tdate, "DD-mmm-YYYY")
End If
End If
Last:
PopulateEstimatesCostsFromResource
End Sub
'' --BSD
Private Sub txtBSD_Enter()
bTriggerFromTaskFormCalendar = True
If txtBSD.Value = vbNullString Then
dFormDate = Date
Else
dFormDate = CDate(txtBSD.Value)
End If
frmDateSelector.Show
If bNoDateSelectedForForm = False Then
txtBSD.Value = Format(dFormDate, "DD-MMM-YYYY")
End If
Me.btnOk.SetFocus
txtBSD_ExitCalculation
bTriggerFromTaskFormCalendar = False
bNoDateSelectedForForm = False
End Sub
Private Sub txtBSD_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtBSD_ExitCalculation
End Sub
Private Sub txtBSD_ExitCalculation()
Dim tdate As Date
frm_Task - 14
End If
GoTo Last
End If
Last:
If txtBSD = vbNullString And txtBED = vbNullString Then txtBD = vbNullString
End Sub
Private Sub txtBD_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtBD_ExitCalculation
End Sub
Private Sub frmBaselineDates_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtBD_ExitCalculation
End Sub
Private Sub txtBD_ExitCalculation()
Dim tdate As Date
Dim wd As Long
txtECS.BackColor = Me.BackColor
txtBCS.BackColor = Me.BackColor
txtACS.BackColor = Me.BackColor
End If
End Function
Sub EnableDisableTasks(B As Boolean)
With Me
'.txtTask.enabled = B
.cmbResource.enabled = True
.cmbPercentageCompleted.enabled = B
If B Then
If LCase(Cells(cRowPos, colPos.PercentageEntryMode).Value) = "automatic" Then
With .cmbPercentageCompleted
.enabled = False
.BackColor = Me.BackColor
End With
End If
End If
.txtStartDate.enabled = B
.txtEndDate.enabled = B
.txtCalendarDays.enabled = B
.txtBSD.enabled = B
.txtBED.enabled = B
.txtBD.enabled = B
.txtASD.enabled = B
.txtAED.enabled = B
.txtAD.enabled = B
.txtNotes.enabled = True
.txtECS.enabled = B
.txtACS.enabled = B
.txtBCS.enabled = B
.btnAddResource.enabled = True
.btnCopyFromEstimatedCosts.enabled = B
.btnCopyFromEstimatedDates.enabled = B
.Label25.enabled = B
.btnAddDependency.enabled = B
.btnEditDependency.enabled = B
.btnDeleteDependency.enabled = B
.lblDependencyType.enabled = B
.lblDelay.enabled = B
.cmbTaskName.enabled = B
.cmbDependencyType.enabled = B
.txtDelay.enabled = B
.lstDependencies.enabled = B
If B Then
Else
.cmbPercentageCompleted.BackColor = Me.BackColor
.txtStartDate.BackColor = Me.BackColor
.txtEndDate.BackColor = Me.BackColor
.txtCalendarDays.BackColor = Me.BackColor
.txtBSD.BackColor = Me.BackColor
.txtBED.BackColor = Me.BackColor
.txtBD.BackColor = Me.BackColor
.txtASD.BackColor = Me.BackColor
.txtAED.BackColor = Me.BackColor
.txtAD.BackColor = Me.BackColor
.txtECS.BackColor = Me.BackColor
.txtACS.BackColor = Me.BackColor
.txtBCS.BackColor = Me.BackColor
.Label25.BackColor = Me.BackColor
.btnAddDependency.BackColor = Me.BackColor
.btnEditDependency.BackColor = Me.BackColor
.btnDeleteDependency.BackColor = Me.BackColor
.lblDependencyType.BackColor = Me.BackColor
.lblDelay.BackColor = Me.BackColor
.cmbTaskName.BackColor = Me.BackColor
.cmbDependencyType.BackColor = Me.BackColor
.txtDelay.BackColor = Me.BackColor
.lstDependencies.BackColor = Me.BackColor
frm_Task - 17
.btnCopyFromEstimatedDates.BackColor = Me.BackColor
End If
End With
End Sub
Sub EnableDisableTasksM(B As Boolean)
With Me
.txtTask.enabled = True
.cmbResource.enabled = True
.txtNotes.enabled = True
.btnAddResource.enabled = True
.txtStartDate.enabled = True
.cmbPercentageCompleted.enabled = False
.txtEndDate.enabled = False
.txtCalendarDays.enabled = False
.txtBSD.enabled = False
.txtBED.enabled = False
.txtBD.enabled = False
.txtASD.enabled = False
.txtAED.enabled = False
.txtAD.enabled = False
.txtECS.enabled = False
.txtACS.enabled = False
.txtBCS.enabled = False
.btnCopyFromEstimatedCosts.enabled = False
.btnCopyFromEstimatedDates.enabled = False
.Label25.enabled = True
.btnAddDependency.enabled = True
.btnEditDependency.enabled = True
.btnDeleteDependency.enabled = True
.lblDependencyType.enabled = True
.lblDelay.enabled = True
.cmbTaskName.enabled = True
.cmbDependencyType.enabled = True
.txtDelay.enabled = True
.lstDependencies.enabled = True
.cmbPercentageCompleted.BackColor = Me.BackColor
.txtEndDate.BackColor = Me.BackColor
.txtCalendarDays.BackColor = Me.BackColor
.txtBSD.BackColor = Me.BackColor
.txtBED.BackColor = Me.BackColor
.txtBD.BackColor = Me.BackColor
.txtASD.BackColor = Me.BackColor
.txtAED.BackColor = Me.BackColor
.txtAD.BackColor = Me.BackColor
.txtECS.BackColor = Me.BackColor
.txtACS.BackColor = Me.BackColor
.txtBCS.BackColor = Me.BackColor
.Label25.BackColor = Me.BackColor
.btnCopyFromEstimatedDates.BackColor = Me.BackColor
End With
End Sub
Sub TriggerPopulateDependencies()
If Cells(clRow, colPos.Task).IndentLevel = Cells(clRow + 1, colPos.Task).IndentLevel - 1 And bE
ditTask Then
Me.lblDependencyMsg.Caption = "Dependencies cannot be set for parent tasks"
Me.lblDependencyMsg.ForeColor = RGB(255, 0, 0)
Me.lblDependencyMsg.Font.Italic = False
Exit Sub
Else
Me.lblDependencyMsg.Caption = "Dependency Details"
End If
frm_Task - 18
AddDependencyTypeToCombobox
AddTaskNamesToDependencyTaskNameSelector
Me.btnEditDependency.enabled = False
Me.btnDeleteDependency.enabled = False
Sub AddTaskNamesToDependencyListBox()
'Add predecessor task names to the dependencies list box reading from the sheet
Dim vStr1, vstr2
Dim I As Integer, j As Integer, dRng As Range, tRow As Long
Set dRng = Range(Cells(cHeaderRow + 1, colPos.tid), Cells(Cells.Rows.Count, colPos.tid))
vStr1 = Split(Cells(clRow, colPos.tDependency).Value, sDependencySeperator)
For I = 0 To UBound(vStr1) - 1
vstr2 = Split(vStr1(I), "_")
tRow = dRng.Find(vstr2(0), , , xlWhole).Row
With Me.lstDependencies
.AddItem vstr2(0)
.List(.ListCount - 1, 1) = Cells(tRow, colPos.WBS).Value & " - " & Cells(tRow, colPos.T
ask).Value
.List(.ListCount - 1, 2) = GetDependencyTypeNameFromCode(CStr(vstr2(1)))
.List(.ListCount - 1, 3) = vstr2(2)
.List(.ListCount - 1, 4) = Cells(tRow, colPos.ESD).Value
.List(.ListCount - 1, 5) = Cells(tRow, colPos.EED).Value
Next
tRow = dRng.Find(vstr2(0), , , xlPart).Row
End Sub
Sub AddDependencyTypeToCombobox()
With Me.cmbDependencyType
.Clear
.AddItem "Finish to Start"
.AddItem "Start to Start"
.AddItem "Finish to Finish"
.AddItem "Start to Finish"
End With
End Sub
Sub UpdateDependenciesToSheetFromForm()
Me.lblCalculatingDependencies.visible = True
Me.Repaint
Dim dRng As Range, tRow As Long
Set dRng = Range(Cells(cHeaderRow + 1, colPos.tid), Cells(Cells.Rows.Count, colPos.tid))
'Read for tDependency and remove the dependents for relates cells
Dim vStr1, vstr2, tj As Integer, ti As Integer, tid As Integer, vstr3, tdStr As String, tiRow A
s Long
With Me.lstDependencies
If .ListCount = 0 Then
Cells(clRow, colPos.tDependency).Value = vbNullString
GoTo Last
End If
CalculateStartEndConstrainsAllRows True
frm_Task - 20
Cells(cRowPos, colPos.ShowGrouping).Value = 0
RefreshRibbon True
End If
Rows(clRow).EntireRow.Insert
Range(Cells(clRow, colPos.WBS), Cells(clRow, colPos.TimelineStart - 1)).Font.Bold = False
If bAddTask Then
Cells(clRow, colPos.tType).Value = "T"
Cells(clRow, colPos.Task).Value = "Adding task..."
Cells(clRow, colPos.Task).IndentLevel = lIndentLevel
ElseIf bAddMilestone Then
Cells(clRow, colPos.tType).Value = "M"
Cells(clRow, colPos.Task).Value = "Adding Milestone..."
Cells(clRow, colPos.Task).IndentLevel = 0
End If
Cells(clRow, colPos.tid).Value = GetNextIDNumber
WBSNumbering
AddBordersToTasks clRow
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Private Sub DeleteInsertedRow()
Application.EnableEvents = False
Rows(clRow).EntireRow.Delete
If Cells(clRow + 1, colPos.tid) <> vbNullString Then AddBordersToTasks clRow
WBSNumbering
Application.EnableEvents = True
End Sub
Task Details Calculating Dependencies...
Actual
Notes
Milestone