Selected Answer
Deleting the stack (or whatever) seems like a good idea. The alternative is to block keyboard action during the Wait. I wonder if this effect might be built into the Sleep function. It's a function of Windows and you have to declare the API before you can use it.
In the same vein, showing a Modal form durng the Wait would inhibit the use of the keyboard and you could tell the user to keep her hands to herself as well as how much longer this unhappy state must continue.
But then I found this thread and now feel that there might be an even better solution there.
The code below will wait for 5 seconds without interrupting the code. During this time the keyboard should be locked.
Private Sub Wait5Seconds()
Dim Tim As Double
Tim = Timer
Do While Timer < (Tim + 5)
DoEvents
Loop
End Sub
In the following you have the above idea fully implemented in a solution. Try this code on a blank worksheet. In your project replace the MsgBox with your LDAP calls.
Option Explicit
Private Waiting As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)
' 25 May 2018
If Waiting Then
With Application
.EnableEvents = False
.Undo
.EnableEvents = True
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' 25 May 2018
Const Loops As Integer = 3 ' number of LDAP calls: change as needed
Static Cell As Range
Dim Tim As Double
Dim i As Integer
If Waiting Then
Application.EnableEvents = False
Cell.Select
Application.EnableEvents = True
Else
Set Cell = Target
Waiting = True
Do
i = i + 1
MsgBox "Making LDAP call No. " & i
If i = Loops Then Exit Do
Tim = Timer
Do While Timer < (Tim + 5)
DoEvents
Loop
Loop
Waiting = False
End If
End Sub