LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Using If Statements and a Time Variable

I am trying to run a macro upon opening a Workbook that will display a
short message based on the time of day.
If the current time is less than the time i.e. in mytime then it will
dipslay a "Good Morning Message in a box." Which is accomplished
when it goes to the Good Morning code.

My problem is that i cannot the the VBA to work and display (Good
Morning, Good Afternoon, or Good Night).

I cannot get it to work for all time variables. It seems that the
time is only read by its value such as if the current time its 11:15
PM my first If statement sees it as true. How do i get it to read as
11:15 PM or 23:15:00 (military time)?

Any help?



mytime1 = TimeValue("11:59:00")
mytime2 = TimeValue("20:59:00")
mytime3 = TimeValue("23:59:00")
Sheets("Estimate").Select

If mytime1 Range("mytime") Then
GoTo Good_Morning
Else
If mytime2 Range("mytime") Then
GoTo Good_AFTERNOON
Else
If mytime3 Range("mytime") Then
GoTo Good_Evening
End if

RG

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statements and Time [email protected] Excel Worksheet Functions 4 May 6th 06 06:44 AM
Variable SQL Statements pulling from a cell in Excel Duke Carey Excel Worksheet Functions 2 March 23rd 06 09:35 AM
Variable SQL Statements pulling from a cell in Excel Duke Carey Links and Linking in Excel 2 March 23rd 06 09:35 AM
Variable SQL Statements pulling from a cell in Excel Duke Carey Excel Worksheet Functions 0 March 22nd 06 08:31 PM
Variable SQL Statements pulling from a cell in Excel Duke Carey Links and Linking in Excel 0 March 22nd 06 08:31 PM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"