Calculating a running date column and sorting

mfarr76

New Member
Joined
Jan 3, 2014
Messages
36
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
ABCDE
START DATESTART 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
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top