![]() |
|
#8
|
||||
|
||||
|
Try adding the following macro to your 'Inputs' worksheet's code module:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim StartDate As Date, Duration As Long, i As Long
With ActiveSheet
If Intersect(Target, .Range("D9:D11")) Is Nothing Then Exit Sub
If ActiveSheet.Range("D9") = "" Then Exit Sub
If ActiveSheet.Range("D10") < 1 Then Exit Sub
StartDate = .Range("D9").Value
Duration = .Range("D11").Value
End With
With Worksheets("O&M")
.Range("A5:D" & .UsedRange.Rows.Count).ClearContents
.Range("A5").Value = StartDate
.Range("B5").Value = DateAdd("yyyy", 1, StartDate) - 1
.Range("C" & i + 5).Value = Format(StartDate, "yyyy")
.Range("D" & i + 5).Value = 1
For i = 1 To Duration - 1
.Range("A" & i + 5).Value = DateAdd("yyyy", i, StartDate)
.Range("B" & i + 5).Value = DateAdd("yyyy", i + 1, StartDate) - 1
.Range("C" & i + 5).Value = Format(DateAdd("yyyy", i, StartDate), "yyyy")
.Range("D" & i + 5).Value = i + 1
Next
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] Last edited by macropod; 04-17-2014 at 04:11 PM. Reason: Code revision |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Auto Populate Word From to Excel File
|
webber | Word | 1 | 10-02-2013 02:52 PM |
| Start / End Dates in conjunction with man days | loobs40 | Project | 5 | 09-19-2013 09:21 AM |
| how to populate textbox based on combobox selection in word | IvanGeorgiev | Word | 1 | 02-21-2013 07:32 PM |
how to populate textbox based on combobox selection in word
|
IvanGeorgiev | Word VBA | 1 | 02-21-2013 07:28 PM |
Task Start and End Dates
|
OTPM | Project | 2 | 12-04-2011 09:14 AM |