GuyGadois
Sep 27th, 2005, 12:26 PM
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.
GuySub IntraData()
i = Hour(Time)
If i > 6 Then
If i < 13 Then
Set b = Selection
ad = b.Address
dTime = Now + TimeValue("00:15:00")
Application.OnTime dTime, "IntraData"
Sheets("Intraday").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("D1").Select
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("G&I").Select
Range("X168").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Intraday").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Growth").Select
Range("Y116").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Intraday").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("G&I Summary").Select
Range(ad).Select
End If
End Sub
Edit: Added tags for clarity. - Hack
GuySub IntraData()
i = Hour(Time)
If i > 6 Then
If i < 13 Then
Set b = Selection
ad = b.Address
dTime = Now + TimeValue("00:15:00")
Application.OnTime dTime, "IntraData"
Sheets("Intraday").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("D1").Select
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("G&I").Select
Range("X168").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Intraday").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Growth").Select
Range("Y116").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Intraday").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("G&I Summary").Select
Range(ad).Select
End If
End Sub
Edit: Added tags for clarity. - Hack