hotseetotsee
New Member
- Joined
- Dec 20, 2016
- Messages
- 7
I am trying to populate an End Date for my table based on the Start Date and the Duration stated by the user.
My table are as shown as below:
<tbody>
</tbody>
I have tried to run a VBA code as follows but it returned as Run-Time Error '1004': Application defined or object-defined error
I am new to VBA and I really appreciate if you could help me with this. Thanks.
My table are as shown as below:
Task | Start Date | Duration (day(s)) | End Date |
1 | 5/12/2016 | 5 | |
2 | 7/12/2016 | 7 |
<tbody>
</tbody>
I have tried to run a VBA code as follows but it returned as Run-Time Error '1004': Application defined or object-defined error
Code:
Sub PlannedEndDate()
Dim userInputDate As Date
Dim duration As Double
Dim endDate As Date
userInputDate = Range("C6" & Rows.Count).End(xlUp).Row
duration = Range("D6" & Rows.Count).End(xlUp).Row
endDate = Range("E6" & Rows.Count).End(xlUp).Row
If duration = "" Then
endDate = DateAdd("d", duration, userInputDate)
Else
endDate = userInputDate
End If
End Sub
I am new to VBA and I really appreciate if you could help me with this. Thanks.