Sie sind auf Seite 1von 21

frm_Task - 1

'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()

If Trim(Me.cmbTaskName.Value & vbNullString) = vbNullString Then


MsgBox "Select a task to be added as a dependency", vbInformation, "Information"
Me.cmbTaskName.SetFocus
Exit Sub
End If
If Me.cmbDependencyType.Value = vbNullString Then
MsgBox "Select dependency type", vbInformation, "Information"
Me.cmbDependencyType.SetFocus
Exit Sub
End If

If Me.txtDelay.Value = vbNullString Or IsNumeric(Me.txtDelay.Value) = False Then


Me.txtDelay.Value = 0
End If
With Me.lstDependencies
.AddItem Me.cmbTaskName.List(Me.cmbTaskName.ListIndex, 0)
.List(.ListCount - 1, 1) = Me.cmbTaskName.List(Me.cmbTaskName.ListIndex, 1)
.List(.ListCount - 1, 2) = Me.cmbDependencyType.Value
.List(.ListCount - 1, 3) = Me.txtDelay.Value
End With

'Delete Selected Task


Me.cmbTaskName.RemoveItem (Me.cmbTaskName.ListIndex)
If Me.cmbTaskName.ListCount = 0 Then Me.btnAddDependency.enabled = False

Me.cmbTaskName.ListIndex = -1
Me.cmbDependencyType.ListIndex = -1
Me.txtDelay.Value = vbNullString
End Sub

Private Sub btnClearDependencyInputs_Click()


Me.cmbTaskName.Value = vbNullString
Me.txtDelay.Value = vbNullString
Me.cmbDependencyType.Value = vbNullString
End Sub

Private Sub btnDeleteDependency_Click()


Me.lstDependencies.RemoveItem (Me.lstDependencies.ListIndex)
lstDependencies_Click
AddTaskNamesToDependencyTaskNameSelector
End Sub

Private Sub btnEditDependency_Click()


If Me.lstDependencies.ListCount = 0 Then Exit Sub
If btnEditDependency.Caption = "Edit" Then
Me.btnAddDependency.enabled = False
Me.btnDeleteDependency.enabled = False
Me.btnClearDependencyInputs.enabled = False
Me.lstDependencies.enabled = False
With Me.cmbTaskName
.Style = fmStyleDropDownCombo
.Text = Me.lstDependencies.List(Me.lstDependencies.ListIndex, 1)
.enabled = False
End With
If Me.lstDependencies.List(Me.lstDependencies.ListIndex, 2) = "Finish to Start" Then
Me.cmbDependencyType.ListIndex = 0
ElseIf Me.lstDependencies.List(Me.lstDependencies.ListIndex, 2) = "Start to Start" Then
Me.cmbDependencyType.ListIndex = 1
ElseIf Me.lstDependencies.List(Me.lstDependencies.ListIndex, 2) = "Finish to Finish" Then
Me.cmbDependencyType.ListIndex = 2
ElseIf Me.lstDependencies.List(Me.lstDependencies.ListIndex, 2) = "Start to Finish" Then
Me.cmbDependencyType.ListIndex = 3
End If

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

Private Sub cmbResource_Change()


If bfDiasabledEvents Then Exit Sub
PopulateEstimatesCostsFromResource
End Sub

Private Sub cmbResource_Enter()


btnAddResource_Click
Me.btnAddResource.SetFocus
End Sub

Private Sub cmbTaskName_AfterUpdate()


If Me.cmbDependencyType.Value = vbNullString Then Me.cmbDependencyType.ListIndex = 0 ' = "Fi
nish to Start"
End Sub

Private Sub cmbTaskName_Change()


If Me.cmbDependencyType = vbNullString Then Me.cmbDependencyType.ListIndex = 0 ' = "Finish t
o Start"
End Sub

Private Sub lstDependencies_Click()

If Me.lstDependencies.ListIndex <> -1 Then


Me.btnEditDependency.enabled = True
Me.btnEditDependency.Caption = "Edit"
Me.btnDeleteDependency.enabled = True
Else
Me.btnEditDependency.enabled = False
Me.btnDeleteDependency.enabled = False
Me.btnEditDependency.Caption = "Save"
End If
End Sub
Private Sub btnAddResource_Click()
bAddResourceValueToFormNotToCell = True
sResourcesNamesFromForm = Me.cmbResource.Value
frm_ResourceSelector.Show

Me.cmbResource.Value = sResourcesNamesFromForm
sResourcesNamesFromForm = vbNullString
bAddResourceValueToFormNotToCell = False
End Sub

Private Sub btnCopyFromEstimatedCosts_Click()


Me.txtBCS.Value = Me.txtECS.Value
End Sub

Private Sub btnCopyFromEstimatedDates_Click()


PopulateBaseDates
End Sub

Private Sub cmbResource_AfterUpdate()


PopulateEstimatesCostsFromResource
End Sub
frm_Task - 3

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

Private Sub lstDependencies_DblClick(ByVal Cancel As MSForms.ReturnBoolean)


lstDependencies_Click
If Me.lstDependencies.ListIndex <> -1 Then
btnEditDependency_Click
End If
End Sub

Private Sub txtDelay_AfterUpdate()


If Me.txtDelay.Value = vbNullString Or IsNumeric(Me.txtDelay.Value) = False Then
Me.txtDelay.Value = 0
Else
Me.txtDelay.Value = CLng(Me.txtDelay.Value)
End If
End Sub

Private Sub UserForm_Initialize()


ReCalculateColPos
#If Mac Then
#Else
With Me
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
End With
#End If

bfDiasabledEvents = True
Dim sTmp As String, I As Long
Me.lblCalculatingDependencies.visible = False
If bAddTask Or bAddMilestone Then InsertNewRow

If bAddTask Or bAddMilestone Then AddNewTaskLoad


If bEditTask Or bEditMilestone Then EditTaskLoad
'If bAddMilestone Then fAddNewMilestoneLoad
'If bEditMilestone Then fEditNewMilestoneLoad

If bAddMilestone = True Or bEditMilestone = True Then Me.chkMilestone.Value = True


If IsParentTask(clRow) Then Me.chkMilestone.enabled = False

If LCase(Cells(cRowPos, colPos.PercentageEntryMode).Value) = "automatic" Then


With Me.cmbPercentageCompleted
.enabled = False
.BackColor = Me.BackColor
End With
End If

If bAddTask = True Or bAddMilestone = True Then


EnableDisableTasks True
ElseIf Cells(clRow, colPos.Task).IndentLevel = Cells(clRow + 1, colPos.Task).IndentLevel - 1 An
d bEditTask = True Then
EnableDisableTasks False
Me.lblDependencyMsg.Caption = "Dependencies cannot be set for parent tasks"
Me.lblDependencyMsg.ForeColor = RGB(255, 0, 0)
Me.lblDependencyMsg.Font.Italic = False
End If
AddResourcesToComboBox

If GetLicType = sLProV Or GetLicType = sLTrialV Then


'Me.Width = 375
Me.cmbTaskName.enabled = False
Me.cmbDependencyType.enabled = False
frm_Task - 4

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.lblDependencyMsg.Caption = "Dependency Details"


Else
'Me.Width = 760
TriggerPopulateDependencies
Me.cmbDependencyType.Value = vbNullString
End If

If bAddTask Or bAddMilestone Then Me.txtTask.SetFocus


bfDiasabledEvents = False
End Sub
Sub AddResourcesToComboBox()
Exit Sub
End Sub
Private Sub btnCancel_Click()
Unload Me
End Sub
Private Sub UserForm_Terminate()
If bDontDelete = False Then
If bAddTask Or bAddMilestone Then DeleteInsertedRow
End If
End Sub

Private Sub fAddNewMilestoneLoad()

Me.Caption = "Add Milestone"


Me.lbl_Task.Caption = "Name"
Me.Label26.Caption = cTaskWBSBeingAdded & "Milestone Details"

Me.txtStartDate.Value = Format(Now(), "dd-mmm-yyyy")


Me.cmbPercentageCompleted.Value = 0
End Sub
Private Sub AddNewTaskLoad()
Dim tclrow As Long
If bAddTask Then
Me.Caption = "Add Task"
Else
Me.Caption = "Add Milestone"
End If
If bEditMilestone = True Then Me.chkMilestone = True
Me.lbl_Task.Caption = "Task Name"

Me.Label26.Caption = cTaskWBSBeingAdded & " Details"

Me.txtStartDate.Value = Format(Now(), "dd-mmm-yyyy")


With Me.cmbPercentageCompleted
Dim I As Long
For I = 0 To 100
.AddItem I
Next
End With

Me.cmbPercentageCompleted.Value = 0

EnableDisableCosts
End Sub

Private Sub EditTaskLoad()


With Me.cmbPercentageCompleted
Dim I As Long
For I = 0 To 100
.AddItem I
Next
frm_Task - 5

End With

Me.Caption = "Edit Task"


Me.Label26.Caption = Cells(clRow, colPos.WBS).Value & " - " & " Details"

If bEditMilestone = True Then Me.chkMilestone = True

Me.txtNotes.Value = Cells(clRow, colPos.Notes).Value


Me.txtTask.Value = Cells(clRow, colPos.Task).Value

Me.cmbResource.Value = Cells(clRow, colPos.TaskLead).Value


If IsNumeric(Cells(clRow, colPos.PercentageCompleted).Value) Then Me.cmbPercentageCompleted.Val
ue = CLng(Cells(clRow, colPos.PercentageCompleted).Value * 100)

If Cells(clRow, colPos.ESD).Value <> vbNullString And IsDate(Cells(clRow, colPos.ESD).Value) =


False Then
Me.txtStartDate.Value = vbNullString
ElseIf IsDate(Cells(clRow, colPos.ESD).Value) Then
Me.txtStartDate.Value = Format(Cells(clRow, colPos.ESD).Value, "DD-MMM-YYYY")
End If
If Cells(clRow, colPos.EED).Value <> vbNullString And IsDate(Cells(clRow, colPos.EED).Value) =
False Then
Me.txtEndDate.Value = vbNullString
ElseIf IsDate(Cells(clRow, colPos.EED).Value) Then
Me.txtEndDate.Value = Format(Cells(clRow, colPos.EED).Value, "DD-MMM-YYYY")
End If
Me.txtCalendarDays.Value = Cells(clRow, colPos.ED).Value

If Cells(clRow, colPos.BSD).Value <> vbNullString And IsDate(Cells(clRow, colPos.BSD).Value) =


False Then
Me.txtBSD.Value = vbNullString
ElseIf IsDate(Cells(clRow, colPos.EED).Value) Then
Me.txtBSD.Value = Format(Cells(clRow, colPos.BSD).Value, "DD-MMM-YYYY")
End If

If Cells(clRow, colPos.BED) <> vbNullString And IsDate(Cells(clRow, colPos.BED).Value) = False


Then
Me.txtBED.Value = vbNullString
ElseIf IsDate(Cells(clRow, colPos.EED).Value) Then
Me.txtBED.Value = Format(Cells(clRow, colPos.BED).Value, "DD-MMM-YYYY")
End If

Me.txtBD = Cells(clRow, colPos.BD).Value

If Cells(clRow, colPos.ASD).Value <> vbNullString And IsDate(Cells(clRow, colPos.ASD).Value) =


False Then
Me.txtASD.Value = vbNullString
ElseIf IsDate(Cells(clRow, colPos.ASD).Value) Then
Me.txtASD.Value = Format(Cells(clRow, colPos.ASD).Value, "DD-MMM-YYYY")
End If
If Cells(clRow, colPos.AED).Value <> vbNullString And IsDate(Cells(clRow, colPos.AED).Value) =
False Then
Me.txtAED = vbNullString
ElseIf IsDate(Cells(clRow, colPos.EED).Value) Then
Me.txtAED = Format(Cells(clRow, colPos.AED).Value, "DD-MMM-YYYY")
End If
Me.txtAD = Cells(clRow, colPos.AD).Value

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

Me.txtResourceCost.Value = Cells(clRow, colPos.TaskLeadCost).Value


End If

If bEditTask = True Or bEditMilestone = True Then


If dblClickCol = colPos.WBS Or dblClickCol = colPos.Task Then
Me.txtTask.SetFocus
ElseIf dblClickCol = colPos.TaskLead Then
Me.cmbResource.SetFocus
ElseIf dblClickCol = colPos.ESD Then
With Me.txtStartDate
.SetFocus
.SelStart = 0
frm_Task - 6

.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

If txtASD.Value = vbNullString Then


dFormDate = Date
Else
dFormDate = CDate(txtASD.Value)
End If
frmDateSelector.Show
If bNoDateSelectedForForm = False Then
txtASD.Value = Format(dFormDate, "DD-MMM-YYYY")
End If
Me.btnOk.SetFocus
PopulateActualDates "S"
bTriggerFromTaskFormCalendar = False
bNoDateSelectedForForm = False
End Sub
Private Sub txtASD_Exit(ByVal Cancel As MSForms.ReturnBoolean)
PopulateActualDates "S"
End Sub
Private Sub txtAED_Enter()
bTriggerFromTaskFormCalendar = True
If txtAED.Value = vbNullString Then
dFormDate = Date
Else
dFormDate = CDate(txtAED.Value)
End If
frmDateSelector.Show
If bNoDateSelectedForForm = False Then
txtAED.Value = Format(dFormDate, "DD-MMM-YYYY")
End If
Me.btnOk.SetFocus
PopulateActualDates "E"
bTriggerFromTaskFormCalendar = False
bNoDateSelectedForForm = False
End Sub
Private Sub txtAED_Exit(ByVal Cancel As MSForms.ReturnBoolean)
PopulateActualDates "E"
End Sub

Private Sub PopulateActualDates(Optional t As String)


If IsDate(txtASD) = False Then
txtASD.Value = vbNullString
Else
txtASD.Value = Format(txtASD.Value, "DD-MMM-YYYY")
End If

If IsDate(txtAED) = False Then


txtAED.Value = vbNullString
Else
txtAED.Value = Format(txtAED.Value, "DD-MMM-YYYY")
End If

If txtAED.Value <> vbNullString And txtASD.Value <> vbNullString Then


If CDate(txtASD.Value) > CDate(txtAED.Value) Then
'MsgBox "Actual End date cannot be before start date", vbInformation, "Information"
If t = "S" Then
txtAED = vbNullString
Else
txtASD = vbNullString
End If
Exit Sub
End If
Me.txtAD.Value = GetWorkDaysFromDate(txtASD.Value, txtAED.Value)
End If
Last:
End Sub

Private Sub btnOk_Click()


LogTimeStamp "ClickedOk Start:"

If Me.cmbTaskName <> vbNullString Then


MsgBox "Please complete adding the dependency and try again.", vbInformation, "Information"
Exit Sub
End If

If Me.txtEndDate.Value = vbNullString Then txtCalendarDays_ExitCalculation


frm_Task - 8

If Me.txtBED.Value = vbNullString Then txtBD_ExitCalculation

If Me.cmbPercentageCompleted.Value = vbNullString Then Me.cmbPercentageCompleted.Value = 0

If Me.txtEndDate.Value = vbNullString And Me.txtStartDate.Value = vbNullString Then


MsgBox "Enter estimated start and end dates", vbInformation, "Information"
Me.txtEndDate.SetFocus
Exit Sub
End If

If IsNumeric(Me.cmbPercentageCompleted.Value) = False Then


MsgBox "Enter only numbers for percentage completed", vbInformation, "Information"
Me.cmbPercentageCompleted.SetFocus
Exit Sub
End If

If Me.txtTask.Value = vbNullString Then


MsgBox "Enter task name", vbInformation, "Information"
Me.txtTask.SetFocus
Exit Sub
End If
If Me.txtStartDate.Value = vbNullString Then
MsgBox "Enter estimated start date", vbInformation, "Information"
Me.txtStartDate.SetFocus
Exit Sub
End If
If Me.txtEndDate.Value = vbNullString Then
MsgBox "Enter estimated end date", vbInformation, "Information"
Me.txtEndDate.SetFocus
Exit Sub
End If

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

LogTimeStamp "ClickedOk End:"


End Sub
Private Sub btnOk_AddSection()
Exit Sub
End Sub
Private Sub btnOk_EditSection()
Exit Sub
frm_Task - 9

End Sub

Private Sub btnOk_AddEditTask()


Dim cRow As Long, errMsg As String
UnLockSheet ActiveSheet
DisableAll
If bAddTask Or bAddMilestone Then

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

Cells(clRow, colPos.ESD).HorizontalAlignment = xlRight


Cells(clRow, colPos.EED).HorizontalAlignment = xlRight
Cells(clRow, colPos.ED).HorizontalAlignment = xlRight

Cells(clRow, colPos.ASD).HorizontalAlignment = xlRight


Cells(clRow, colPos.AED).HorizontalAlignment = xlRight
Cells(clRow, colPos.AD).HorizontalAlignment = xlRight

Cells(clRow, colPos.BCS).HorizontalAlignment = xlRight


Cells(clRow, colPos.ECS).HorizontalAlignment = xlRight
Cells(clRow, colPos.ACS).HorizontalAlignment = xlRight

Cells(clRow, colPos.ResourceCost).HorizontalAlignment = xlRight

If clRow = cHeaderRow + 1 Then


With Range(Cells(cHeaderRow + 1, colPos.WBS), Cells(cHeaderRow + 1, colPos.TimelineMaxE
nd))
.Interior.Color = RGB(255, 255, 255)
.Font.Color = RGB(0, 0, 0)
.Font.Italic = False
.RowHeight = 16
.Font.Bold = 0
End With
AlignCells (Cells(clRow, colPos.Task))
End If

With Range(Cells(clRow, colPos.WBS), Cells(clRow, colPos.TimelineMaxEnd)).Interior


.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With

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

Cells(clRow, colPos.BLColor).Interior.Color = Cells(cRowPos, colPos.BaselineTimelineColor).


Value
Cells(clRow, colPos.ACColor).Interior.Color = Cells(cRowPos, colPos.ActualTimelineColor).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

Cells(clRow, colPos.ESD).Value = CDate(Me.txtStartDate.Value)


Cells(clRow, colPos.EED).Value = CDate(Me.txtEndDate.Value)
Cells(clRow, colPos.PercentageCompleted).Value = Me.cmbPercentageCompleted.Value / 100
Cells(clRow, colPos.ED).Value = CLng(Me.txtCalendarDays.Value)
frm_Task - 10

If Me.txtResourceCost.Value <> vbNullString Then


Cells(clRow, colPos.TaskLeadCost).Value = CLng(Me.txtResourceCost.Value)
Else
Cells(clRow, colPos.TaskLeadCost).Value = vbNullString
End If

If bAddTask = True Or bEditTask = True Or bAddMilestone = True Or bEditMilestone = True Then


If IsDate(Me.txtBED.Value) And Me.txtBED.Value <> vbNullString Then
Cells(clRow, colPos.BED).Value = CDate(Me.txtBED.Value)
Else
Cells(clRow, colPos.BED).Value = vbNullString
End If

If IsDate(Me.txtBSD.Value) And Me.txtBSD.Value <> vbNullString Then


Cells(clRow, colPos.BSD).Value = CDate(Me.txtBSD.Value)
Else
Cells(clRow, colPos.BSD).Value = vbNullString
End If

If Me.txtBD.Value <> vbNullString Then


Cells(clRow, colPos.BD).Value = CLng(Me.txtBD.Value)
Else
Cells(clRow, colPos.BD).Value = vbNullString
End If

If IsDate(Me.txtAED.Value) And Me.txtAED.Value <> vbNullString Then


Cells(clRow, colPos.AED).Value = CDate(Me.txtAED.Value)
Else
Cells(clRow, colPos.AED).Value = vbNullString
End If

If IsDate(Me.txtASD.Value) And Me.txtASD.Value <> vbNullString Then


Cells(clRow, colPos.ASD).Value = CDate(Me.txtASD.Value)
Else
Cells(clRow, colPos.ASD).Value = vbNullString
End If

If Me.txtAD.Value <> vbNullString Then


Cells(clRow, colPos.AD).Value = CLng(Me.txtAD.Value)
Else
Cells(clRow, colPos.AD).Value = vbNullString
End If

If Me.txtASD.Value = vbNullString And Me.txtAED.Value = vbNullString Then Cells(clRow, colP


os.AD).Value = vbNullString

If Me.txtECS.Value <> vbNullString Then


Cells(clRow, colPos.ECS).Value = CLng(Me.txtECS.Value)
Else
Cells(clRow, colPos.ECS).Value = vbNullString
End If
If Me.txtBCS.Value <> vbNullString Then
Cells(clRow, colPos.BCS).Value = CLng(Me.txtBCS.Value)
Else
Cells(clRow, colPos.BCS).Value = vbNullString
End If
If Me.txtACS.Value <> vbNullString Then
Cells(clRow, colPos.ACS).Value = CLng(Me.txtACS.Value)
Else
Cells(clRow, colPos.ACS).Value = vbNullString
End If
End If

Cells(clRow, colPos.Notes).Value = Me.txtNotes.Value

If bAddTask = True Or bAddMilestone = True Then


Cells(clRow, colPos.Task).IndentLevel = lIndentLevel
End If
End Sub

Private Sub PopulateBaseDates()


Application.EnableEvents = False
frm_Task - 11

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

If txtStartDate.Value = vbNullString And IsDate(txtEndDate.Value) And txtCalendarDays.Value > 0


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
GoTo Last
End If

If IsDate(txtStartDate.Value) And IsDate(txtEndDate.Value) Then


If CDate(txtStartDate.Value) > CDate(txtEndDate.Value) Then
txtEndDate.Value = vbNullString
GoTo Last
Else
txtCalendarDays.Value = GetWorkDaysFromDate(CDate(txtStartDate.Value), CDate(txtEndDate
.Value))
End If
GoTo Last
End If
Last:
PopulateEstimatesCostsFromResource
End Sub

Private Sub txtEndDate_Enter()


bTriggerFromTaskFormCalendar = True
If txtEndDate.Value = vbNullString Then
dFormDate = Date
Else
dFormDate = CDate(txtEndDate.Value)
End If
frmDateSelector.Show
If bNoDateSelectedForForm = False Then
txtEndDate.Value = Format(dFormDate, "DD-MMM-YYYY")
End If
Me.btnOk.SetFocus
txtEndDate_ExitCalculation
bTriggerFromTaskFormCalendar = False
bNoDateSelectedForForm = False
End Sub
Private Sub txtEndDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtEndDate_ExitCalculation
End Sub
Private Sub txtEndDate_ExitCalculation()
Dim tdate As Date
If IsDate(txtEndDate.Value) = False Then
txtEndDate = vbNullString
GoTo Last
ElseIf txtEndDate.Value < csDate Or txtEndDate > ceDate Then
ShowOutofDatesMessage
txtEndDate.Value = vbNullString
txtEndDate.SetFocus
GoTo Last
Else
txtEndDate.Value = Format(txtEndDate.Value, "DD-MMm-YYYY")
End If

If txtEndDate.Value = vbNullString And IsDate(txtStartDate.Value) And txtCalendarDays.Value > 0


Then
tdate = Format(GetStartFromWorkDays(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
GoTo Last
End If

If IsDate(txtStartDate.Value) And IsDate(txtEndDate.Value) Then


If CDate(txtEndDate.Value) < CDate(txtStartDate.Value) Then
txtStartDate.Value = vbNullString
GoTo Last
frm_Task - 13

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

If IsDate(txtBSD) = False Then


txtBSD.Value = vbNullString
GoTo Last
ElseIf txtBSD.Value < csDate Or txtBSD.Value > ceDate Then
ShowOutofDatesMessage
txtBSD.Value = vbNullString
GoTo Last
Else
txtBSD.Value = Format(txtBSD.Value, "DD-MMm-YYYY")
End If
If txtBSD.Value = vbNullString And IsDate(txtBED.Value) And txtBD.Value > 0 Then
tdate = Format(GetStartFromWorkDays(CDate(txtBED.Value), txtBD.Value), "dd-mmm-yyyy")

If tdate < csDate Or tdate > ceDate Then


ShowOutofDatesMessage
txtBSD.Value = vbNullString
GoTo Last
Else
txtBSD.Value = Format(tdate, "DD-mmm-yyyy")
End If
GoTo Last
End If

If IsDate(txtBSD.Value) And IsDate(txtBED.Value) Then


If CDate(txtBSD.Value) > CDate(txtBED.Value) Then
'MsgBox "Start date cannot be later than end date", vbInformation, "Information"
txtBED.Value = vbNullString
GoTo Last
Else
txtBD.Value = GetWorkDaysFromDate(CDate(txtBSD.Value), CDate(txtBED.Value))
End If
GoTo Last
End If
Last:
If txtBSD = vbNullString And txtBED = vbNullString Then txtBD = vbNullString
End Sub
Private Sub txtBED_Enter()
bTriggerFromTaskFormCalendar = True
If txtBED.Value = vbNullString Then
dFormDate = Date
Else
dFormDate = CDate(txtBED.Value)
End If
frmDateSelector.Show
If bNoDateSelectedForForm = False Then
txtBED.Value = Format(dFormDate, "DD-MMM-YYYY")
End If
Me.btnOk.SetFocus
txtBED_ExitCalculation
bTriggerFromTaskFormCalendar = False
bNoDateSelectedForForm = False
End Sub
Private Sub txtBED_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtBED_ExitCalculation
End Sub
Private Sub txtBED_ExitCalculation()
Dim tdate As Date
If IsDate(txtBED.Value) = False Then
txtBED.Value = vbNullString
GoTo Last
ElseIf txtBED.Value < csDate Or txtBED.Value > ceDate Then
ShowOutofDatesMessage
txtBED.Value = vbNullString
GoTo Last
Else
txtBED.Value = Format(txtBED.Value, "DD-MMm-YYYY")
End If

If txtBED = vbNullString And IsDate(txtBSD.Value) And txtBD.Value > 0 Then


tdate = Format(GetStartFromWorkDays(CDate(txtBSD.Value), txtBD.Value), "dd-mmm-yyyy")

If tdate < csDate Or tdate > ceDate Then


ShowOutofDatesMessage
txtBED.Value = vbNullString
GoTo Last
Else
txtBED.Value = Format(tdate, "DD-mmm-yyyy")
frm_Task - 15

End If
GoTo Last
End If

If IsDate(txtBSD.Value) And IsDate(txtBED.Value) Then


If CDate(txtBED.Value) < CDate(txtBSD.Value) Then
txtBSD.Value = vbNullString
GoTo Last
Else
txtBD.Value = GetWorkDaysFromDate(CDate(txtBSD.Value), CDate(txtBED.Value))
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

If IsDate(txtBSD.Value) And IsDate(txtBED.Value) Then


wd = GetWorkDaysFromDate(CDate(txtBSD.Value), CDate(txtBED.Value))
If txtBD = vbNullString Then txtBD = wd
If wd <> txtBD.Value Then
tdate = Format(GetEndDateFromWorkDays(CDate(txtBSD.Value), txtBD.Value), "DD-mmm-yyyy")
If tdate > ceDate Or tdate < csDate Then
ShowOutofDatesMessage
txtBED.Value = vbNullString
Else
txtBED.Value = Format(tdate, "DD-mmm-YYYY")
End If
End If
GoTo Last
ElseIf IsDate(txtBSD.Value) And txtBED.Value = vbNullString Then
If txtBD.Value = vbNullString Then txtBD = 1
tdate = Format(GetEndDateFromWorkDays(CDate(txtBSD.Value), txtBD.Value), "DD-MMM-YYYY")
If tdate > ceDate Or tdate < csDate Then
ShowOutofDatesMessage
txtBED.Value = vbNullString
Else
txtBED.Value = Format(tdate, "DD-mmm-YYYY")
End If
ElseIf txtBSD.Value = vbNullString And IsDate(txtBED.Value) Then
If txtBD.Value = vbNullString Then txtBD = 1
tdate = Format(GetStartFromWorkDays(CDate(txtBED.Value), txtBD.Value), "DD-mmm-YYYY")
If tdate > ceDate Or tdate < csDate Then
ShowOutofDatesMessage
txtBSD.Value = vbNullString
Else
txtBSD.Value = Format(tdate, "DD-mmm-YYYY")
End If
End If
Last:
End Sub
Function EnableDisableCosts()
If Cells(cRowPos, colPos.CostsModule) And (bEditTask Or bAddTask) Then
txtECS.enabled = True
txtBCS.enabled = True
txtACS.enabled = True
Me.btnCopyFromEstimatedCosts.enabled = True

txtECS.BackColor = RGB(255, 255, 255)


txtBCS.BackColor = RGB(255, 255, 255)
txtACS.BackColor = RGB(255, 255, 255)
Else
txtECS.enabled = False
txtBCS.enabled = False
txtACS.enabled = False
Me.btnCopyFromEstimatedCosts.enabled = False
frm_Task - 16

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

If (bEditTask Or bEditMilestone) And Cells(clRow, colPos.tDependency) <> vbNullString Then


AddTaskNamesToDependencyListBox
End If

Me.btnEditDependency.enabled = False
Me.btnDeleteDependency.enabled = False

If Me.cmbTaskName.ListCount = 0 Then Me.btnAddDependency.enabled = False


End Sub
Sub AddTaskNamesToDependencyTaskNameSelector()
Dim tid As Variant
Dim lRow As Long, CurrentID As Long

'Get List of task IDs to the collection


lRow = cHeaderRow + 1
Set tIDList = Nothing
Do Until Cells(lRow, 1) = vbNullString
tIDList.Add lRow, "K" & Cells(lRow, colPos.tid)
lRow = lRow + 1
Loop
CurrentID = Cells(clRow, colPos.tid).Value

'Remove current selection from the collection


tIDList.Remove "K" & CurrentID
GetNonDependentIDs clRow

If tIDList Is Nothing Then GoTo Last


Dim c
Me.cmbTaskName.Clear
For Each c In tIDList
With Me.cmbTaskName
.AddItem Cells(c, colPos.tid).Value
'Task ID
.List(.ListCount - 1, 1) = Cells(c, colPos.WBS).Value & " - " & Cells(c, colPos.Task).V
alue ' TaskWBS - Task Name
.List(.ListCount - 1, 2) = Cells(c, colPos.ESD).Value
' Task ESD
.List(.ListCount - 1, 3) = Cells(c, colPos.EED).Value
' Task EED
End With
Next
Last:
Set tIDList = Nothing

If Me.cmbTaskName.ListCount <> 0 Then btnAddDependency.enabled = True


End Sub

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

'Remove this task ID from the Task Dependency Combobox Selector


For j = 0 To Me.cmbTaskName.ListCount - 1
If Me.cmbTaskName.List(j, 0) = vstr2(0) Then
Me.cmbTaskName.RemoveItem (j)
Exit For
End If
Next
End With
frm_Task - 19

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()

If Cells(clRow, colPos.tDependency).Value = vbNullString And Cells(clRow, colPos.tDependents).V


alue = vbNullString And Me.lstDependencies.ListCount = 0 Then
Exit Sub
End If

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

If Cells(clRow, colPos.tDependency).Value <> vbNullString Then


vStr1 = Split(Cells(clRow, colPos.tDependency).Value, sDependencySeperator)
For ti = 0 To UBound(vStr1) - 1
vstr2 = Split(vStr1(ti), "_")

'Find the row of this id in vstr2 and replace clrow id


tiRow = dRng.Find(vstr2(0), , , xlWhole).Row
vstr3 = Split(Cells(tiRow, colPos.tDependents).Value, sDependencySeperator)
For tj = 0 To UBound(vstr3) - 1
If CLng(vstr3(tj)) = Cells(clRow, colPos.tid).Value Then
Else
tdStr = tdStr & vstr3(tj) & sDependencySeperator
End If
Next tj
Cells(tiRow, colPos.tDependents).Value = tdStr
tdStr = vbNullString
Next ti
End If

With Me.lstDependencies
If .ListCount = 0 Then
Cells(clRow, colPos.tDependency).Value = vbNullString
GoTo Last
End If

Dim dRow As Long, sDependencies As String

'form dependency string and add ID to dependent string in parent task


For dRow = 0 To .ListCount - 1
sDependencies = sDependencies & .List(dRow, 0) & "_" & GetDependencyTypeCodeFromName(.L
ist(dRow, 2)) & "_" & .List(dRow, 3) & sDependencySeperator
tRow = dRng.Find(.List(dRow, 0), , , xlWhole).Row
If InStr(1, sDependencySeperator & Cells(tRow, colPos.tDependents).Value, sDependencySe
perator & Cells(clRow, colPos.tid).Value & sDependencySeperator, vbTextCompare) = 0 Then
Cells(tRow, colPos.tDependents).Value = Cells(tRow, colPos.tDependents).Value & Cel
ls(clRow, colPos.tid).Value & sDependencySeperator
End If
Next

Cells(clRow, colPos.tDependency).Value = sDependencies


Cells(clRow, colPos.tStartConstrain).Value = vbNullString
Cells(clRow, colPos.tEndConstrain).Value = vbNullString
Last:

CalculateStartEndConstrainsAllRows True
frm_Task - 20

ReCalculateConstrainsValues clRow, True


End With
End Sub
Private Sub InsertNewRow()
If CBool(Cells(cRowPos, colPos.ShowGrouping).Value) = True Then
Application.EnableEvents = False
ActiveSheet.Cells.EntireRow.ClearOutline

Cells(cRowPos, colPos.ShowGrouping).Value = 0
RefreshRibbon True
End If

Dim lRowHeight As Double


With Application
.EnableEvents = False
.ScreenUpdating = True
.CutCopyMode = False
End With

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...

Task Name Predecessor - Task/Milestone Name

Resources Select Resource Rate


Add Save Delete Clear
Start Date End Date Days
Estimated

Baseline Copy from Estimated

Actual

Estimated Baseline Actual


Costs Copy from Estimated

Estimated Produced % Completed


Quantity

Notes

Milestone

Das könnte Ihnen auch gefallen