+ Reply to Thread
Results 1 to 16 of 16

VBA Sleep code time interval question

Hybrid View

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,802

    Re: VBA Sleep code time interval question

    Create a new standard module or use an existing one (like Module1) and add the API code at the top of the module
    Option Explicit
    
    #If VBA7 Then
    
        Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 'For 64-Bit versions of Excel
    
    #Else
    
        Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32-Bit versions of Excel
    
    #End If
    Then in your worksheet module update your existing code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Intersect(Target, Range("J34")) Is Nothing Then Exit Sub
        
        MsgBox "REMINDER: After filling out info for this row, click the Archive and Reset Sheet button", vbOKOnly
        Shapes("Archive_Reset").Fill.ForeColor.RGB = vbRed
        Sleep 500 'milliseconds (pause for 0.5 second)
        Shapes("Archive_Reset").Fill.ForeColor.RGB = vbBlue
        Sleep 500 'milliseconds (pause for 0.5 second)
        
    End Sub
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  2. #2
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office 365
    Posts
    259

    Re: VBA Sleep code time interval question

    Thanks Jeff, I tested this out but it actually isn't changing the shapes color after I click "OK" on the message box that pops up when typing something into J34. It was changing the color before with the Application.Wait line but for this after clicking OK, it stays the same color and has a bit of a delay before you can click in another cell. That delay in being able to click was expected, but the lack of color change wasn't. Were you getting a different result?
    Last edited by PitchNinja; 09-11-2024 at 03:21 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Check if the in and out time falls between a specific time interval
    By srivibish in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-27-2020, 03:18 AM
  2. Sleep command question
    By Joven76 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2018, 08:21 PM
  3. VBA calculate sleep time, when time is entered in military time format
    By axm1955 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-29-2017, 10:28 AM
  4. Replies: 11
    Last Post: 10-24-2016, 08:12 PM
  5. [SOLVED] VBA code to find if station is booked in certain date and time interval
    By sysss in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2016, 06:24 PM
  6. Replies: 1
    Last Post: 04-29-2014, 04:42 AM
  7. Replies: 0
    Last Post: 04-23-2012, 10:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1