+ Reply to Thread
Results 1 to 4 of 4

Open workbook macro if time is between???

  1. #1
    Registered User
    Join Date
    06-29-2006
    Posts
    15

    Open workbook macro if time is between???

    I'm using this open_workbook macro-
    Please Login or Register  to view this content.
    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

  2. #2
    Charlie
    Guest

    RE: 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. #3
    Tom Ogilvy
    Guest

    RE: 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. #4
    Registered User
    Join Date
    06-29-2006
    Posts
    15
    Great-- It works perfectly thanks so much for the help!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1