Hello,
I could use some help coding a script that will calculate a running date column that is calculated based upon criteria that is entered into specific cells. I am able to write basic code that can do this.
I am running into trouble when the previous calculations have meet its criteria (number of steps-shown in B8), I want to start a new calculation, with "START DATE 2" (E2) and use the same time steps parameters. I want to continue this in the same cells as the previous calculations and then, I would like to be able to sort the date column oldest to newest.
Any help would be greatly appreciated!
Excel 2010
<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
I could use some help coding a script that will calculate a running date column that is calculated based upon criteria that is entered into specific cells. I am able to write basic code that can do this.
I am running into trouble when the previous calculations have meet its criteria (number of steps-shown in B8), I want to start a new calculation, with "START DATE 2" (E2) and use the same time steps parameters. I want to continue this in the same cells as the previous calculations and then, I would like to be able to sort the date column oldest to newest.
Any help would be greatly appreciated!
Excel 2010
A | B | C | D | E | |
---|---|---|---|---|---|
2 | START DATE | 1/1/2016 | START DATE 2 | 6/1/2016 | |
3 | SPUD TO RR | 20 | |||
4 | RIG MOVE | 2 | |||
5 | RR TO FRAC | 10 | |||
6 | FRAC TO SALES | 20 | |||
7 | TOTAL SPUD TO SALES | 52 | |||
8 | NUMBER OF STEPS | 25 | |||
9 | |||||
10 | SPUD | RR | COMPL | START | |
11 | 1/1/2016 | 1/21/2016 | 1/31/2016 | 2/20/2016 | |
12 | 1/23/2016 | 2/12/2016 | 2/22/2016 | 3/13/2016 | |
13 | 2/14/2016 | 3/5/2016 | 3/15/2016 | 4/4/2016 | |
14 | 3/7/2016 | 3/27/2016 | 4/6/2016 | 4/26/2016 | |
15 | 3/29/2016 | 4/18/2016 | 4/28/2016 | 5/18/2016 | |
16 | 4/20/2016 | 5/10/2016 | 5/20/2016 | 6/9/2016 |
<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1
Code:
Sub STARTDATES()
Dim SRR As Integer
Dim RM As Integer
Dim RF As Integer
Dim FS As Integer
Dim n As Integer
Dim m As Integer
Dim sd As Date
Dim sd2 As Date
With Sheets("sheet1")
sd = .Cells(2, 2)
SRR = Cells(3, 2)
RM = .Cells(4, 2)
RF = .Cells(5, 2)
FS = .Cells(6, 2)
n = .Cells(8, 2)
sd2 = .Cells(2, 5)
sd3 = .Cells(3, 5)
sd4 = .Cells(4, 5)
Cells(11, 2).Value = sd
Cells(11, 3).Value = Cells(11, 2).Value + SRR
Cells(11, 4).Value = Cells(11, 3).Value + RF
Cells(11, 5).Value = Cells(11, 4).Value + FS
For i = 1 To n
'RR TO MOVE RIG
Cells(11 + i, 2).Value = Cells(10 + i, 3).Value + RM
'SPUD TO RR
Cells(11 + i, 3).Value = Cells(11 + i, 2).Value + SRR
'RR TO FRAC
Cells(11 + i, 4).Value = Cells(11 + i, 3).Value + RF
'FRAC TO SALES
Cells(11 + i, 5).Value = Cells(11 + i, 4).Value + FS
Next i
Finalrow = Cells(Rows.Count, 2).End(xlUp).Row
Cells(Finalrow + 1, 2).Value = sd2
End With
End Sub