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>
[TD="align: center"]2[/TD]
[TD="align: right"]1/1/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"]6/1/2016[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"]52[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]25[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: center"]SPUD[/TD]
[TD="align: center"]RR[/TD]
[TD="align: center"]COMPL[/TD]
[TD="align: center"]START[/TD]
[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/1/2016[/TD]
[TD="align: right"]1/21/2016[/TD]
[TD="align: right"]1/31/2016[/TD]
[TD="align: right"]2/20/2016[/TD]
[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/23/2016[/TD]
[TD="align: right"]2/12/2016[/TD]
[TD="align: right"]2/22/2016[/TD]
[TD="align: right"]3/13/2016[/TD]
[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"]2/14/2016[/TD]
[TD="align: right"]3/5/2016[/TD]
[TD="align: right"]3/15/2016[/TD]
[TD="align: right"]4/4/2016[/TD]
[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3/7/2016[/TD]
[TD="align: right"]3/27/2016[/TD]
[TD="align: right"]4/6/2016[/TD]
[TD="align: right"]4/26/2016[/TD]
[TD="align: center"]15[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3/29/2016[/TD]
[TD="align: right"]4/18/2016[/TD]
[TD="align: right"]4/28/2016[/TD]
[TD="align: right"]5/18/2016[/TD]
[TD="align: center"]16[/TD]
[TD="align: right"][/TD]
[TD="align: right"]4/20/2016[/TD]
[TD="align: right"]5/10/2016[/TD]
[TD="align: right"]5/20/2016[/TD]
[TD="align: right"]6/9/2016[/TD]
</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 | |
---|---|---|---|---|---|
START DATE | START DATE 2 | ||||
SPUD TO RR | |||||
RIG MOVE | |||||
RR TO FRAC | |||||
FRAC TO SALES | |||||
TOTAL SPUD TO SALES | |||||
NUMBER OF STEPS | |||||
<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]2[/TD]
[TD="align: right"]1/1/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"]6/1/2016[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"]52[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]25[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="align: center"]SPUD[/TD]
[TD="align: center"]RR[/TD]
[TD="align: center"]COMPL[/TD]
[TD="align: center"]START[/TD]
[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/1/2016[/TD]
[TD="align: right"]1/21/2016[/TD]
[TD="align: right"]1/31/2016[/TD]
[TD="align: right"]2/20/2016[/TD]
[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/23/2016[/TD]
[TD="align: right"]2/12/2016[/TD]
[TD="align: right"]2/22/2016[/TD]
[TD="align: right"]3/13/2016[/TD]
[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="align: right"]2/14/2016[/TD]
[TD="align: right"]3/5/2016[/TD]
[TD="align: right"]3/15/2016[/TD]
[TD="align: right"]4/4/2016[/TD]
[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3/7/2016[/TD]
[TD="align: right"]3/27/2016[/TD]
[TD="align: right"]4/6/2016[/TD]
[TD="align: right"]4/26/2016[/TD]
[TD="align: center"]15[/TD]
[TD="align: right"][/TD]
[TD="align: right"]3/29/2016[/TD]
[TD="align: right"]4/18/2016[/TD]
[TD="align: right"]4/28/2016[/TD]
[TD="align: right"]5/18/2016[/TD]
[TD="align: center"]16[/TD]
[TD="align: right"][/TD]
[TD="align: right"]4/20/2016[/TD]
[TD="align: right"]5/10/2016[/TD]
[TD="align: right"]5/20/2016[/TD]
[TD="align: right"]6/9/2016[/TD]
</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