Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open workbook macro if time is between???


I'm using this open_workbook macro-

Code:
--------------------
Private Sub Workbook_Open()
ImportData

End Sub
--------------------


I want it to only import the data if the workbook is opened between
9:30 pm and 9:40 pm

So I've been trying to use all diff types of time iff statements and I
can't figure out the right way to state it?

If Time = "21:30:00", <="21:40:00"
then

but it won't let me put in the comma? I've also tried ( )'s!! Where
am I going wrong? Do I need to use NowTime or just Now? Any help
would be awesome-- Thanks- Mike


--
buzzharley
------------------------------------------------------------------------
buzzharley's Profile: http://www.excelforum.com/member.php...o&userid=35886
View this thread: http://www.excelforum.com/showthread...hreadid=558952

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Open workbook macro if time is between???

If Time = "21:30:00" and time <="21:40:00" then


"buzzharley" wrote:


I'm using this open_workbook macro-

Code:
--------------------
Private Sub Workbook_Open()
ImportData

End Sub
--------------------


I want it to only import the data if the workbook is opened between
9:30 pm and 9:40 pm

So I've been trying to use all diff types of time iff statements and I
can't figure out the right way to state it?

If Time = "21:30:00", <="21:40:00"
then

but it won't let me put in the comma? I've also tried ( )'s!! Where
am I going wrong? Do I need to use NowTime or just Now? Any help
would be awesome-- Thanks- Mike


--
buzzharley
------------------------------------------------------------------------
buzzharley's Profile: http://www.excelforum.com/member.php...o&userid=35886
View this thread: http://www.excelforum.com/showthread...hreadid=558952


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Open workbook macro if time is between???

Private Sub Workbook_Open()
Dim dTime as Date
dTime = Time
if dTime = TimeValue("9:30 AM") and _
dTime < TimeValue("9:40 AM") then
ImportData
end if
End Sub


demo'd from the immediate window:

? time
11:55:58 AM
? time = timevalue("12:30 PM")
False
? time <= timeValue("12:30 PM")
True

--
Regards,
Tom Ogilvy


"buzzharley" wrote:


I'm using this open_workbook macro-

Code:
--------------------
Private Sub Workbook_Open()
ImportData

End Sub
--------------------


I want it to only import the data if the workbook is opened between
9:30 pm and 9:40 pm

So I've been trying to use all diff types of time iff statements and I
can't figure out the right way to state it?

If Time = "21:30:00", <="21:40:00"
then

but it won't let me put in the comma? I've also tried ( )'s!! Where
am I going wrong? Do I need to use NowTime or just Now? Any help
would be awesome-- Thanks- Mike


--
buzzharley
------------------------------------------------------------------------
buzzharley's Profile: http://www.excelforum.com/member.php...o&userid=35886
View this thread: http://www.excelforum.com/showthread...hreadid=558952


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open workbook macro if time is between???


Great-- It works perfectly thanks so much for the help!!!


--
buzzharley
------------------------------------------------------------------------
buzzharley's Profile: http://www.excelforum.com/member.php...o&userid=35886
View this thread: http://www.excelforum.com/showthread...hreadid=558952

Reply
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
Open Workbook at a certain time jswalsh33 Excel Worksheet Functions 2 February 20th 10 01:12 PM
How do I set up a workbook to open on a cell reference every time CAHM Excel Discussion (Misc queries) 2 November 30th 07 05:41 PM
Able to open same excel workbook at the same time ! ann[_3_] Excel Programming 4 May 10th 06 01:46 PM
Why does Excel 2003 open on 3rd tab of workbook every time, not l. Excelfrustrated Excel Worksheet Functions 2 February 7th 05 08:15 PM
How to stop having to re-assign macros every time you open a workbook??? Simon Lloyd[_533_] Excel Programming 3 August 16th 04 03:27 AM


All times are GMT +1. The time now is 12:49 PM.

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

About Us

"It's about Microsoft Excel"