help with looping dates

S

srroduin

Help, this is driving me crazy.

So far I have the User typing in the start (column A) and the final date
(column K).
I need to loop it so that eventually every date between the start and final
will show up in Column A as a new start date and as the end date for the day
above (column B). It will continue to loop until the new start date = the
final date of the outage in Column K. I either get an endless loop or get
errors. Any help is much appreciated. The code for this is the DailySAS at
the bottom. The first start date and the final date come from the OutageSAS
code just below. Thanks!


Sub OutageSAS()
Dim SASStart As String
Dim SASEnd As String
Dim rng As Range


Set rng = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
SASIncrease = InputBox("Input the SAS # you want to increase, e.g. 11003")
SASDecrease = InputBox("Input the SAS # you want to decrease, e.g. 11006")
SASMW = InputBox("Enter new MW Amount")

rng.Offset(4, 0).Value = InputBox("Enter start date mm/dd/yyyy of event")


rng.Offset(4, 10).Value = InputBox("Enter stop date mm/dd/yyyy")


Set rng = Nothing

WkshtName = ActiveSheet.Name

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Set wks1 = Workbooks("SAS Excel File111.xls").Worksheets(WkshtName)
Set wks2 = Workbooks("SAS Excel File111.xls").Worksheets("SAS UPLOAD")
Set wks3 = Workbooks("SAS Excel File111.xls").Worksheets("Outage")

Call GetName

SASType = InputBox("Enter the Type of SAS As Shown in example, e.g.
daily,hourly,flat")

If SASType = "daily" Then

Call DailySAS
Else
If SASType = "hourly" Then
'Call HourlySAS

Else
SASType = "flat"


End If
End If

End Sub

Sub DailySAS()
Dim rng As Range

Range("A5").Value = "Start Date"
Range("C5").Value = "Stop Date"
Range("E5").Value = "SAS Increased"
Range("E6" & i).Value = SASIncrease
Range("G5").Value = "SAS Decreased"
Range("G6" & i).Value = SASDecrease
Range("I5").Value = "MW Amount"
Range("I6" & i).Value = SASMW
Range("K5").Value = "Final Date of Outage"

Set rng = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)

rng.Value = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Value + 1

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top