AbdelrahmanExcel
New Member
- Joined
- Dec 24, 2024
- Messages
- 1
- Office Version
- 2021
- Platform
- Windows
Dears
i am creating simple task tracker to add task with due dates
some times one of team member has assigned task with fixed frequency such as every day , every week ...etc
i am trying to make macro code to write the frequency period and type required , and the excel automatically add tasks according to assigned period
i have tried this code but not work
Kindly support
i am creating simple task tracker to add task with due dates
some times one of team member has assigned task with fixed frequency such as every day , every week ...etc
i am trying to make macro code to write the frequency period and type required , and the excel automatically add tasks according to assigned period
i have tried this code but not work
Kindly support
VBA Code:
Sub Task_MakeRecurring()
Dim Freq As Long
Dim FreqQty As Long
Dim TotTime As Double
Dim StartOnDt As Date, UntilDt As Date, StartDt As Date, EndDt As Date
With Main
'If .Range("b5").Value = Empty Then
'MsgBox "Please make sure to enter a Task Name before saving"
'Exit Sub
'End If
'If .Range("b7").Value = Empty Or .Range("b8").Value = Empty Then
' MsgBox "Please make sure task has Start and End Dates to make them recurring"
' Exit Sub
' End If
' If .Range("B1").Value < 4 Then
'MsgBox "Please make sure to enter Recurring Frequency, Start On and Until Date fields to make this task Recurring"
' Exit Sub
' End If
TotTime = .Range("g2").Value 'Total Time
FreqQty = .Range("b14").Value 'Frequency Qty
Freq = .Range("b13").Value 'Frequency
StartOnDt = .Range("b15").Value 'Start On Date
UntilDt = .Range("b16").Value 'Until Date
StartDt = StartOnDt 'Set Initial Starting Date
EndDt = StartDt + TotTime 'End Date is Start Date + Total Time
Do While StartDt <= UntilDt 'Create Tasks Until Start Date is greater than Until Date
.Range("b7").Value = StartDt 'Set Starting Date
.Range("b8").Value = Int(EndDt) 'Set Ending Date (date as a whole number)
Call Add_Data 'Save Task
'Update Start & End Dates for Next Task
Select Case Freq
Case Is = "Day(s)"
StartDt = DateAdd("d", FreqQty, StartDt)
Case Is = "Week(s)"
StartDt = DateAdd("ww", FreqQty, StartDt)
Case Is = "Months(s)"
StartDt = DateAdd("m", FreqQty, StartDt)
End Select
EndDt = StartDt + TotTime 'Update End Date
Loop
End With
Call Add_Data 'Update Task list
End Sub