30 second delay

Rubber Beaked Woodpecker

Board Regular
Joined
Aug 30, 2015
Messages
203
Office Version
  1. 2021
Hi. The following code works very well but I would like a slight modification. When S1 = 1 I would like a 30 second delay before the code is executed. I've tried in several way using Application.Wait but cannot get this to work.

Any advice please :)

Thanks
RBW

VBA Code:
Option Explicit

Dim currentMarket As String
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Sheet1").Calculate
 If Target.Columns.Count = 16 Then
    Application.EnableEvents = False
    Range("Q1").Value = WorksheetFunction.CountIf(Range("H5:H50"), ">0")
    Range("Q2") = Range("W2")
     Range("U1") = Range("U2")
      Range("T1") = Range("T2")
       Range("AA1") = Range("Z1")
                      If Range("S1") = 1 Then

                '30 second delay    

          Call ThisSheetlogBalance
                  
          Call Completed
         
         
                           ElseIf Range("X2").Value = "Yes" Then
             Call R1
                                   
        End If
   End If
  
   Application.EnableEvents = True
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I use this for Access but I think it also works in Excel:

VBA Code:
Sub pause(sngSecs As Single)
Dim endTime As Long

endTime = Timer
Do Until Timer > endTime + sngSecs
Loop

End Sub
You'd call it as
VBA Code:
Range("AA1") = Range("Z1")
If Range("S1") = 1 Then
   Pause 30
   Call ThisSheetlogBalance
 
Upvote 0
Solution
Thanks for the acknowledgement. Forgot to say that by using single as the data type it allows you to use fractional seconds, such as 5.5
Glad I could help.
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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