Consulting

Results 1 to 2 of 2

Thread: Auto click OK button

  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Posts
    21
    Location

    Auto click OK button

    i have a program that makes a user enter data into cell and if there is nothing in a cell a message box pop up
    also in my program i have a close workbook function if open for more than 10 mins, which works as long as the user does not forget to click ok button on the pop message box.

    Sub Auto_Open()
    
    Application.OnTime Now + TimeValue("00:10:00"), "CloseMe"
    End Sub
    Sub CloseMe()
    Worksheets("Sheet2").Range("F1").Copy
    Worksheets("Final Use").Range("D13").PasteSpecial Paste:=xlPasteValues
    Sheets("Final Use").Range("D11").ClearContents
    Sheets("QAT USE").Range("C11").ClearContents
    Sheets("QAT USE").Range("C13").ClearContents
    Sheets("QAT USE").Range("C15").ClearContents
    Sheets("QAT USE").Range("C17").ClearContents
    Sheets("QAT USE").Range("C19").ClearContents
    Application.DisplayAlerts = False
    
    
    ThisWorkbook.Save
    ThisWorkbook.Close
    End Sub
    
    Sub FA_ButtClick()
    
    Set TL = Range("D13")
    If IsEmpty(Range("D11").Value) = True Then
     MsgBox " Please enter a Serial Number"
     Else
     If TL.Value = "Select team lead from drop down menu" Then
     MsgBox "Please choose a Team Lead from the drop down menu"
     Else
    Sheets("Log").Unprotect
    
    
    'Call Call_CopySendRangeFA
    
    
    Worksheets("Sheet2").Range("F1").Copy
    Worksheets("Final Use").Range("D13").PasteSpecial Paste:=xlPasteValues
    Sheets("Final Use").Range("D11").ClearContents
    
    
    Sheets("Log").Protect , _
         AllowFiltering:=True
         Application.DisplayAlerts = False
    ThisWorkbook.Save
    ThisWorkbook.Close
    
    
    End If
    End If
    
    
    End Sub

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    I wouldn't use SendKeys or the Scripting Popup - I've found they're not too reliable

    I'd just make a userform that looks like a MsgBox or something nicer that can time out or be closed by the user
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •