Hello all.
With my "Production Day" being 7:00 AM to 7:00 AM
I am trying to workout some code that will check the current date and time, and if between the two date/times of 7:00 AM, then calculate only the eTime
If after the 7:00 AM, then advance the start and end date/times, then do the calculations.
It seems not to be working the way I am expecting it.
Here is what I have.
With my "Production Day" being 7:00 AM to 7:00 AM
I am trying to workout some code that will check the current date and time, and if between the two date/times of 7:00 AM, then calculate only the eTime
If after the 7:00 AM, then advance the start and end date/times, then do the calculations.
It seems not to be working the way I am expecting it.
Here is what I have.
VBA Code:
Sub ProductionDay()
Dim eTimeStamp As Date
Dim eStartDate As Date
Dim eEndDate As Date
Dim eTime As Range
With Sheets("Admin")
Range("eTimeStamp").Formula = "=Now()"
' If button click time is between the start date/time and _
end date/time then calculate data only
If ((eTimeStamp >= eStartDate) And (eTimeStamp <= eEndDate)) Then
Range("eTime").Calculate 'Calculates data for the current day
Else
' If button click time is after end date/time of 7:00 AM then insert formula into _
cells advancing the date/time by one then calculate data
If ((eTimeStamp >= eStartDate) And (eTimeStamp >= eEndDate)) Then
Range("eStartDate").FormulaR1C1 = "=Today() + TimeValue(""07:00:00"")"
Range("eEndDate").FormulaR1C1 = "=(Today()+1) + TimeValue(""07:00:00"")"
'Calculate other date cells with formulas
Range("eTime").Calculate
End If
Sheets("6AM").Calculate
If Not Application.CalculationState = xlDone Then
DoEvents
End If
End If
End With
End Sub