Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Macro Stops Time

Status
Not open for further replies.

athlon551

Technical User
Apr 19, 2005
4
US
When I run macro1 I can actually see the Time Stop. Any Help would be appreciated.

Sub Macro1()
' Macro recorded 7/13/2005 by Matt Kerg
Repeat:
Time = Now
Length = Len(Time)
SpaceStr = InStr(1, Time, ":")
NewLength = Length - SpaceStr - 4
ReportTime = Left(Time, NewLength)
SampleTime = Right(ReportTime, 2)

If LastTime = SampleTime Then
DoEvents
DoEvents
DoEvents
DoEvents
DoEvents
DoEvents
DoEvents
DoEvents
DoEvents
DoEvents
DoEvents
Else
Call Macro2
LastTime = SampleTime
Range("I2").FormulaR1C1 = ReportTime
Range("J2").FormulaR1C1 = "=R[4]C[-8]"
Range("K2").FormulaR1C1 = "=R[5]C[-9]"
Range("L2").FormulaR1C1 = "=R[6]C[-10]"
End If

GoTo Repeat
End Sub
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 7/13/2005 by Matt Kerg

For X = 122 To 2 Step -1
Range("I" & X) = Range("I" & X - 1)
Range("J" & X).Value = Range("J" & X - 1).Value
Range("K" & X).Value = Range("K" & X - 1).Value
Range("L" & X).Value = Range("L" & X - 1).Value
Next X
End Sub
 

Hi,

Before I attempt an answer, what is your objective with these macros?

Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 


BTW,

Time is a reserve word. I'd use another variable name.

Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 

Seems that SampleTime is the MINUTES of NOW. so the other branch is true and processes once every minute.

Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 

Code:
        t1 = Now
        ReportTime = Format(t1, "hh:mm")
        SampleTime = Format(t1, "nn")
your ReportTime does not reflect AM/PM. This will. Format the cells either for AM/PM or military time.

If you do this, then TIME will NOT stand still.

Here I thought that Joshua had some competition!

Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top