Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 47
Default handle error in IF ELSEIF statement

Hello-

I have the following code that checks 3 scenarios in an IF statement,
and sends an email to a select group if the conditions are true.

If Workbooks("Sr Rep Stats").Worksheets("Combined").Range("d4").Value
0.03 Then

Call CentreVuSeniorA
ElseIf Workbooks("Sr Rep Stats").Worksheets("Combined").Range
("d3").Value 0.03 Then
Call CentreVuSeniorB
ElseIf Workbooks("Sr Rep Stats").Worksheets("Combined").Range
("d2").Value 0.03 Then
Call CentreVuSeniorC
Else
End If
Application.DisplayAlerts = False
Application.Quit

"d4" is a combined number for city A & city B, "d3" is city A, and
"d2" is city B. The problem I am having is that this code starts
running at 7:00 am via task scheduler, and there are times that "d3"
might show #DIV/0! as it is a calculated cell and there might not be
statistics for city A at 7:00am.

I tried to add a bit of code to this line to only look at the 2nd IF
statement when the time is greater than 7:00 AM, but it did not work:

If Workbooks("Sr Rep Stats").Worksheets("Combined").Range("d3").Value
0.03 And Time TimeSerial(7, 0, 0) Then

Call CenrteVuSeniorB

Any ideas?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default handle error in IF ELSEIF statement

If time is the first condition place that first..as below. I have not
modified the code but re-arranged the conditions..

Dim wsTemp As Worksheet
Set wsTemp = Workbooks("Sr Rep Stats").Worksheets("Combined")

'If time greater than 7
If Time TimeSerial(7, 0, 0) Then
If wsTemp.Range("d3").Value 0.03 Then Call CenrteVuSeniorB
Else
If wsTemp.Range("d4").Value 0.03 Then
Call CentreVuSeniorA
ElseIf wsTemp.Range("d3").Value 0.03 Then
Call CentreVuSeniorB
ElseIf wsTemp.Range("d2").Value 0.03 Then
Call CentreVuSeniorC
End If
End If

'Quit
Application.DisplayAlerts = False
Application.Quit



If this post helps click Yes
---------------
Jacob Skaria


"Sabosis" wrote:

Hello-

I have the following code that checks 3 scenarios in an IF statement,
and sends an email to a select group if the conditions are true.

If Workbooks("Sr Rep Stats").Worksheets("Combined").Range("d4").Value
0.03 Then

Call CentreVuSeniorA
ElseIf Workbooks("Sr Rep Stats").Worksheets("Combined").Range
("d3").Value 0.03 Then
Call CentreVuSeniorB
ElseIf Workbooks("Sr Rep Stats").Worksheets("Combined").Range
("d2").Value 0.03 Then
Call CentreVuSeniorC
Else
End If
Application.DisplayAlerts = False
Application.Quit

"d4" is a combined number for city A & city B, "d3" is city A, and
"d2" is city B. The problem I am having is that this code starts
running at 7:00 am via task scheduler, and there are times that "d3"
might show #DIV/0! as it is a calculated cell and there might not be
statistics for city A at 7:00am.

I tried to add a bit of code to this line to only look at the 2nd IF
statement when the time is greater than 7:00 AM, but it did not work:

If Workbooks("Sr Rep Stats").Worksheets("Combined").Range("d3").Value
0.03 And Time TimeSerial(7, 0, 0) Then

Call CenrteVuSeniorB

Any ideas?

Thanks

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
Elseif? ibrokit Excel Worksheet Functions 5 November 25th 08 04:28 PM
Compile Error ElseIf Without If.........But there is an If ! ??? dim Excel Discussion (Misc queries) 11 December 30th 07 07:01 PM
How do I handle error conditions with the FIND command? mywebaccts (at) PLUGcomcast.net Excel Worksheet Functions 6 August 5th 07 12:14 AM
Fill handle turned into a move handle Northwoods Excel Discussion (Misc queries) 1 March 2nd 07 03:40 PM
if elseif flow23 Excel Discussion (Misc queries) 0 November 14th 05 02:09 PM


All times are GMT +1. The time now is 09:20 AM.

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

About Us

"It's about Microsoft Excel"