PC Review


Reply
Thread Tools Rate Thread

Custom Format Time Code

 
 
Texas Aggie
Guest
Posts: n/a
 
      4th Jun 2008
Here's my code:

Dim time As Range
Dim ws As Worksheet
Set ws = ActiveSheet
Set time = ws.Range(B10)

If time.Value = Format(Range("TimeLeft").Value, "00:00:10:00") Then
MsgBox ("Prepare to begin Meeting")
End If

What I am trying to do is display a message when the clock reached 10
minutes or 00:00:10:00. The format of the cell is dd:hh:mm:ss;@. Thanks in
advance.
--

Fighting Texas Aggie Class of 2009
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      4th Jun 2008
If time.Value = TimeSertial(0,10,0) Then
MsgBox ("Prepare to begin Meeting")
End If


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Texas Aggie" <(E-Mail Removed)> wrote in message
news:201A6665-B0B3-410B-9E01-(E-Mail Removed)...
> Here's my code:
>
> Dim time As Range
> Dim ws As Worksheet
> Set ws = ActiveSheet
> Set time = ws.Range(B10)
>
> If time.Value = Format(Range("TimeLeft").Value, "00:00:10:00") Then
> MsgBox ("Prepare to begin Meeting")
> End If
>
> What I am trying to do is display a message when the clock reached 10
> minutes or 00:00:10:00. The format of the cell is dd:hh:mm:ss;@. Thanks in
> advance.
> --
>
> Fighting Texas Aggie Class of 2009



 
Reply With Quote
 
Texas Aggie
Guest
Posts: n/a
 
      4th Jun 2008
No work.

Here is the whole module code. Maybe there is something else influencing it.

Public RunWhen As Double
Public Const cRunIntervalSeconds = 1 ' one second
Public Const cRunWhat = "DateTimeStamp"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=True
End Sub

Sub DateTimeStamp()
Dim ws As Worksheet
Set ws = Worksheets("Welcome")
ws.Range("Date").Value = Format(Now, "dddd mmm dd, yyyy")
ws.Range("L4").Value = Format(Now, "mm/dd/yyyy")
ws.Range("Time").Value = Format(time, "hh:mm:ss AM/PM")
StartTimer
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=False
End Sub

Sub WarningMsg()

Dim time As Range
Dim ws As Worksheet
Set ws = ActiveSheet
Set time = ws.Range(B10)

If time.Value = Format(Range("TimeLeft").Value, "03:13:15:30") Then
MsgBox ("Prepare to begin Meeting")
End If

If time.Value = Format(Range("TimeLeft").Value, "03:13:15:20") Then
MsgBox ("Begin Meeting")
End If
End Sub

--

Fighting Texas Aggie Class of 2009


"Bob Phillips" wrote:

> If time.Value = TimeSertial(0,10,0) Then
> MsgBox ("Prepare to begin Meeting")
> End If
>
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Texas Aggie" <(E-Mail Removed)> wrote in message
> news:201A6665-B0B3-410B-9E01-(E-Mail Removed)...
> > Here's my code:
> >
> > Dim time As Range
> > Dim ws As Worksheet
> > Set ws = ActiveSheet
> > Set time = ws.Range(B10)
> >
> > If time.Value = Format(Range("TimeLeft").Value, "00:00:10:00") Then
> > MsgBox ("Prepare to begin Meeting")
> > End If
> >
> > What I am trying to do is display a message when the clock reached 10
> > minutes or 00:00:10:00. The format of the cell is dd:hh:mm:ss;@. Thanks in
> > advance.
> > --
> >
> > Fighting Texas Aggie Class of 2009

>
>
>

 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      4th Jun 2008
I can't figure out what you're trying to do with Format...

For instance, "03:13:15:30" is certainly not a valid time format.

In general, you don't need to worry about format at all when you're
dealing with the cell .Value property. Since XL stores values as
fractional days, you could just check if your "TimeLeft" range contains
a time value of 10 minutes or less:

Public Sub WarningMsg()
Static bAlreadyWarned
With ActiveSheet.Range("TimeLeft")
If .Value <= 0 Then
MsgBox "Begin Meeting"
ElseIf .Value <= TimeSerial(0, 10, 0) Then
If Not bAlreadyWarned Then
MsgBox "Prepare for Meeting"
bAlreadyWarned = True
End If
End If
End With
End Sub


In article <C2E04220-D528-4716-989B-(E-Mail Removed)>,
Texas Aggie <(E-Mail Removed)> wrote:

> No work.
>
> Here is the whole module code. Maybe there is something else influencing it.
>
> Public RunWhen As Double
> Public Const cRunIntervalSeconds = 1 ' one second
> Public Const cRunWhat = "DateTimeStamp"
>
> Sub StartTimer()
> RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
> Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
> Schedule:=True
> End Sub
>
> Sub DateTimeStamp()
> Dim ws As Worksheet
> Set ws = Worksheets("Welcome")
> ws.Range("Date").Value = Format(Now, "dddd mmm dd, yyyy")
> ws.Range("L4").Value = Format(Now, "mm/dd/yyyy")
> ws.Range("Time").Value = Format(time, "hh:mm:ss AM/PM")
> StartTimer
> End Sub
>
> Sub StopTimer()
> On Error Resume Next
> Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
> Schedule:=False
> End Sub
>
> Sub WarningMsg()
>
> Dim time As Range
> Dim ws As Worksheet
> Set ws = ActiveSheet
> Set time = ws.Range(B10)
>
> If time.Value = Format(Range("TimeLeft").Value, "03:13:15:30") Then
> MsgBox ("Prepare to begin Meeting")
> End If
>
> If time.Value = Format(Range("TimeLeft").Value, "03:13:15:20") Then
> MsgBox ("Begin Meeting")
> End If
> End Sub
>
> --
>
> Fighting Texas Aggie Class of 2009
>
>
> "Bob Phillips" wrote:
>
> > If time.Value = TimeSertial(0,10,0) Then
> > MsgBox ("Prepare to begin Meeting")
> > End If
> >
> >
> > --
> > HTH
> >
> > Bob
> >
> > (there's no email, no snail mail, but somewhere should be gmail in my addy)
> >
> > "Texas Aggie" <(E-Mail Removed)> wrote in message
> > news:201A6665-B0B3-410B-9E01-(E-Mail Removed)...
> > > Here's my code:
> > >
> > > Dim time As Range
> > > Dim ws As Worksheet
> > > Set ws = ActiveSheet
> > > Set time = ws.Range(B10)
> > >
> > > If time.Value = Format(Range("TimeLeft").Value, "00:00:10:00") Then
> > > MsgBox ("Prepare to begin Meeting")
> > > End If
> > >
> > > What I am trying to do is display a message when the clock reached 10
> > > minutes or 00:00:10:00. The format of the cell is dd:hh:mm:ss;@. Thanks in
> > > advance.
> > > --
> > >
> > > Fighting Texas Aggie Class of 2009

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom real time, time format check bear Microsoft Outlook VBA Programming 1 12th Mar 2010 11:28 PM
Length of time from date/time custom format Andrew Microsoft Excel Misc 2 21st Sep 2009 04:20 PM
Custom time format help PYO1012 Microsoft Excel Misc 1 5th Aug 2009 04:09 AM
Custom Cell format to mimic time format brotherescott@yahoo.com Microsoft Excel Misc 6 7th Nov 2006 09:17 PM
Custom format code and a BUG?! =?Utf-8?B?TmlrbGFz?= Microsoft Excel Worksheet Functions 1 19th Feb 2004 09:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 PM.