Application.Wait (Now + TimeValue("0:00:15"))

landon_humphrey

New Member
Joined
Feb 22, 2010
Messages
14
I have some code with the Application.Wait (Now + TimeValue("0:00:15")) added and it seems to work ok but I do not want to stop the entire program to stop running. This is being used in a condition based monitoring system that needs to run run run.

What I and trying to accomplish is to look at some values and if they change compare then wait a bit then verify then send a notification.

/*************Here is my Code *****************/


Private Sub Worksheet_Change(ByVal Target As Range)
'**********************************************************************
'**********Air % Alert Emailer*****************************************
' Add next group here
' [Line B1] Send e-mail
Dim ZedAE8
Dim commandAE8
Static OldValAE8

'only run this code if E8 has changed ()
If Range("E8").Text = ("#N/A") Then GoTo EndAB1 Else
If Range("E8").Value <> OldValAE8 And Range("E14").Value = 1 Then
OldValAE8 = Range("E8").Value
Range("H8") = OldValAE8
If Range("E8").Value <= 9 Then

Application.Wait (Now + TimeValue("0:00:15"))
If Range("E8").Value <= 9 And Range("E14").Value = 1 And Range("E11").Value <= ("600") Then

ZedAE8 = " [ Line# ] " & Range("E5").Text & " [ Green Light ] " & Range("E14").Text & " [ Air % ] " & Range("E8").Text
commandAE8 = "C:\sendemail\sendemail.exe -s 10.72.80.73 -f B1_oven@denso-diam.com"
commandAE8 = commandAE8 & " -t landon_humphrey@denso-diam.com -u B1 Air % Low Level Alert"
commandAE8 = commandAE8 & " -m B1 Oven Air % Level at or Below 9 " & ZedAE8 & " -q"
commandAE8 = commandAE8 & " -l C:\sendemail\logs\Alert_Emailer_Log.txt"

' Passing one long line to Scripting object. If there is need to add additional parameters, do it before.
Set wsShell = CreateObject("wscript.shell")
Set proc = wsShell.Exec(commandAE8)

Do While proc.Status = 0
'Wait until e-mail is sent...
Application.Wait (Now + TimeValue("0:00:01"))
Loop

Set wsShell = Nothing
Set proc = Nothing
MsgBox "Hello Mister Bibb The Alert Email Has Been Sent"
End If
End If
End If
EndAB1:
'End [Line B1]
End Sub


/*******************************************/


Any suggestions will be greatly appreciated

Respectively
Landon
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top