Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Error on IF 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.programming
external usenet poster
 
Posts: 35,218
Default Error on IF statement

Using .value will return the error. So check first:

if iserror(workbooks(....).worksheets(...).range("d3" ).value) then
'msgbox, skip it, what???
else
'do your stuff here
...

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


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Error on IF statement

On Apr 30, 4:08*pm, Dave Peterson wrote:
Using .value will return the error. *So check first:

if iserror(workbooks(....).worksheets(...).range("d3" ).value) then
* *'msgbox, skip it, what???
else
* *'do your stuff here
* *...





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


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dave-

How would you tell the code to "skip it" if the value is an error?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error on IF statement

That's what the "if iserror(...) then" statement does.

If there's an error, then the "then" portion of the if/then/else statement is
followed. But since there's nothing there, it's skipped.

If there is no error, then the "else" portion is followed. That's where you
would put your code that does the real work.



Sabosis wrote:

On Apr 30, 4:08 pm, Dave Peterson wrote:
Using .value will return the error. So check first:

if iserror(workbooks(....).worksheets(...).range("d3" ).value) then
'msgbox, skip it, what???
else
'do your stuff here
...





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


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Dave-

How would you tell the code to "skip it" if the value is an error?


--

Dave Peterson
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
End of Statement error Squeaky Excel Programming 3 May 28th 08 01:12 PM
Can't fix On Error statement austris Excel Discussion (Misc queries) 7 October 13th 06 07:09 AM
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Path/File access error (Error 75) using Name Statement blayne Excel Programming 7 November 22nd 05 09:20 PM
Path/File access error (Error 75) after using Name Statement blayne Excel Programming 0 November 10th 05 12:33 AM


All times are GMT +1. The time now is 09:02 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"