Results 1 to 4 of 4

Thread: [Resolved] If/Then Woes.. help!

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    4

    [Resolved] If/Then Woes.. help!

    I am trying to implement a if/then statement on the excel spreadsheet macro but it get errors, what am I doing wrong? I want the macro to only run between the hrous of 6:30am and 1:00pm. If it is not between those times then it should exit the macro. If it is between those hours then the macro should start. Any advice? Thanks in advance.

    Guy
    VB Code:
    1. Sub IntraData()
    2.    
    3. i = Hour(Time)
    4.  
    5. If i > 6 Then
    6. If i < 13 Then
    7.  
    8.     Set b = Selection
    9.     ad = b.Address
    10.    
    11.     dTime = Now + TimeValue("00:15:00")
    12.     Application.OnTime dTime, "IntraData"
    13.  
    14.     Sheets("Intraday").Select
    15.     Rows("2:2").Select
    16.     Selection.Insert Shift:=xlDown
    17.     Range("D1").Select
    18.     Selection.Copy
    19.     Range("A2").Select
    20.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    21.         :=False, Transpose:=False
    22.     Sheets("G&I").Select
    23.     Range("X168").Select
    24.     Application.CutCopyMode = False
    25.     Selection.Copy
    26.     Sheets("Intraday").Select
    27.     Range("B2").Select
    28.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    29.         :=False, Transpose:=False
    30.     Sheets("Growth").Select
    31.     Range("Y116").Select
    32.     Application.CutCopyMode = False
    33.     Selection.Copy
    34.     Sheets("Intraday").Select
    35.     Range("C2").Select
    36.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    37.         :=False, Transpose:=False
    38.     Sheets("G&I Summary").Select
    39.  
    40.     Range(ad).Select
    41.  
    42. End If
    43.  
    44. End Sub


    Edit: Added [vbcode][/vbcode] tags for clarity. - Hack
    Last edited by GuyGadois; Sep 27th, 2005 at 05:52 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width