Timer macro

S

sunilpatel

I have data as follows

A1=00:00:30 (representing a counter 00 hours 00 minutes 37 seconds)

B1=00:00:45 (representing a counter 00 hours 00 minutes 42 seconds)

C1=00:01:00

The cells are formatted as hh:mm:ss

i need a macro that will add a certain time interval (positive or negative)
to A1 (via inputbox) e.g +31 seconds
and each subsequent time interval increases or decreases by this amount.
If 31 seconds is inputed

A1 will read "00:01:01"
B1 will read "00:01:16" and
C1 will read "00:01:31"

is there a simple macro that can do this, or will i have to write a long
macro looking at each seperat component i.e hh then mm then ss and using
lots of if s%>60, and if m%>60 and if h%>60 etc etc.....


Sunil
 
C

CFS

Sunil,

You can use TimeSerial function:

Sheets(1).Range("A1") = Sheets(1).Range("A1") + TimeSerial(0, 0, 31)

Function Syntax: TimeSerial(hour, minute, second)

CFS
 
B

Bob Phillips

Dim addon As String

addon = InputBox("Supply time addon in format hh:mm:ss")
Range("A1").Value = Range("A1").Value + TimeValue(addon)
Range("B1").Value = Range("B1").Value + TimeValue(addon)
Range("C1").Value = Range("C1").Value + TimeValue(addon)
 

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