|
-
Sep 27th, 2005, 12:26 PM
#1
Thread Starter
New Member
[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:
Sub 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 [vbcode][/vbcode] tags for clarity. - Hack
Last edited by GuyGadois; Sep 27th, 2005 at 05:52 PM.
-
Sep 27th, 2005, 12:35 PM
#2
Re: If/Then Woes.. help!
hmmmmmmm.........which language is this??????
-
Sep 27th, 2005, 12:37 PM
#3
-
Sep 27th, 2005, 01:11 PM
#4
Re: If/Then Woes.. help!
You have 2 "IF" statements but only 1 "End IF".
Changing
VB Code:
If i > 6 Then
If i < 13 Then
to
should solve your problem.
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|