Monday, August 25, 2014

Application.Wait (Now + #12:00:05 AM#)

--######################################
--this only works in debug mode...sometimes.
-- below gives 5 second delay.
--######################################

Public Sub Workbook_NewSheet(ByVal Sh As Object)
    On Error GoTo err_NewWS
    
    'Debug.Print "test"
    'Dim oWS As Excel.Worksheet
    'Set oWS = Application.Worksheets(ActiveSheet.Name)
    Sh.Activate
    
    Application.Wait (Now + #12:00:05 AM#)
    If Left(Sh.Name, 5) = "Sheet" Then
    
        If Sh.Range("D3").Value = "[$tblSnapshot].[SNAPSHOT_STATUS]" Then
            
            Sh.Range("A3:CK3").AutoFilter Field:=4, Criteria1:="ACKNOWLEDGED"
             Debug.Print "executed " & Sh.Name & " "; Now
        End If
        
    Else
        Debug.Print "DID NOT WORK " & Sh.Name & " "; Now
    End If
    
    'Set oWS = Nothing
exit_NewWS:
    Exit Sub
err_NewWS:
    MsgBox Err.Number & " " & Err.Description
    GoTo exit_NewWS
End Sub

No comments:

Post a Comment