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
2START DATE1/1/2016START DATE 26/1/2016
3SPUD TO RR20
4RIG MOVE2
5RR TO FRAC10
6FRAC TO SALES20
7TOTAL SPUD TO SALES52
8NUMBER OF STEPS25
9
10SPUDRRCOMPLSTART
111/1/20161/21/20161/31/20162/20/2016
121/23/20162/12/20162/22/20163/13/2016
132/14/20163/5/20163/15/20164/4/2016
143/7/20163/27/20164/6/20164/26/2016
153/29/20164/18/20164/28/20165/18/2016
164/20/20165/10/20165/20/20166/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
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,215,432
Messages
6,124,860
Members
449,194
Latest member
HellScout

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