One way:
Public Sub try()
Const dENDTIME As Double = #11:12:13#
Const dINC1 As Double = #00:00:09#
Const dINC2 As Double = #00:00:01#
Dim vResponse As Variant
Dim rCell As Range
Dim dTime As Double
Dim dTemp As Double
Dim dIncrement As Double
dIncrement = dINC1 + dINC2
On Error Resume Next
Do
vResponse = Application.InputBox( _
Prompt:="Enter Start Time:", _
Title:="try", _
Default:="00:00:00", _
Type:=2)
If vResponse = False Then Exit Sub 'user cancelled
dTime = TimeValue(vResponse)
Loop Until Err = 0
On Error GoTo 0
Set rCell = ActiveSheet.Range("A2")
For dTemp = dTime To dENDTIME Step dIncrement
With rCell.Resize(1, 2)
.Cells(1).Value = dTemp
.Cells(2).Value = dTemp + dINC1
.NumberFormat = "hh:mm:ss"
End With
Set rCell = rCell.Offset(1, 0)
Next dTemp
End Sub
In article <(E-Mail Removed)>,
"WMR" <(E-Mail Removed)> wrote:
> I have an algorithm for a certain program. But I need help
> implementing it in Excel. Here is my algorithm:
>
> 1. Take the start time (user inputted): ex. 10:03:05
> 2. Put it in column A, row 2
> 3. Add 9 seconds to start time: ex. 10:03:05 + 0:0:09 = 10:03:14
> (new_time1)
> 4. Put new time in Column B, row 2
> 5. Write down "Event 1" in Column C, row 2.
> 6. Add 1 second to new_time1 (ex: 10:03:14): ex. 10:03:14 + 0:0:01 =
> 10:03:15 (new_time2)
> 7. Put new_time2 in column A, row 3.
> 8. Repeat steps 3 to 6 (incrementing new row in step 6) until end time
> is reach (end time is hard coded).
>
>
> Also, on step 5, I'd like to be able to change Event 1 to Event 2 for
> each consecutive row.
>
> Any tips?
> TIA!
|