+ Reply to Thread
Results 1 to 5 of 5

msgbox disappear until right value entered

Hybrid View

biznez msgbox disappear until right... 06-17-2015, 04:13 PM
stnkynts Re: msgbox disappear until... 06-17-2015, 06:45 PM
LJMetzger Re: msgbox disappear until... 06-19-2015, 03:48 PM
biznez Re: msgbox disappear until... 06-19-2015, 04:14 PM
stnkynts Re: msgbox disappear until... 06-19-2015, 04:35 PM
  1. #1
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    msgbox disappear until right value entered

    Hi,

    looking for vb code where a msgbox only disappears when value "Finished" is entered in cell A1. Until then, the msgbox stays active

    Thanks

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: msgbox disappear until right value entered

    If a message box is active you will not be able to enter data in the sheet. So what you are proposing cannot be accomplished. You could have a message box pop up everytime a value is changed in the worksheet if "Finished" is not in cell A1 or you could set up an inputbox on a loop to force a string to be entered into a cell through the input box. A UserForm could accomplish what you are wanting to do but it is a little bit trickier.
    Last edited by stnkynts; 06-17-2015 at 07:05 PM.

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: msgbox disappear until right value entered

    Hi biznez,

    Try the attached sample workbook which should help you get started. It displays a 'Faux' MsgBox that disappears when cell 'A1' contains 'Finished'.

    You don't have to use my UserForm, you can use your own. The UserForm has to be opened 'NonModally'
    UserForm1.Show False
    
    'or
    
    UserForm1.Show vbModeless
    The code that does the heavy lifting follows:
    Option Explicit
    
    #If VBA7 And Win64 Then
        ' 64 bit Excel
        'The following line is supposed to be RED in 32 bit Excel
        Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    #Else
        ' 32 bit Excel
        Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    #End If
    
    Sub DisplayUserFormAndWaitUntilFinishedIsInCellA1()
    
      Const sSheetNAME = "Main"
      Const sSentinelCELL = "A1"
      Const bMessageBold = True
    
      Dim i As Integer
      
      Dim bNeedMore As Boolean
      
      Dim sData As String
      Dim sValue As String
      
      
      'Initialize the "Custom Message Box' and it's attributes
      Call UseUserFormMsgBox
      Call SetUserFormMsgBoxMessageAttributes("Arial", 16, bMessageBold, vbBlue)
      
      'Display a Message in the Message Box
      sData = "Waiting for 'Finished' to appear in Cell 'A1'"
      Call DisplayUserFormMsgBoxMessageWithRefresh(sData)
      
      bNeedMore = True
      While bNeedMore = True
        
        'Allow Excel to do other things
        DoEvents
        
        'Make the application dormant most of the time
        Sleep 250
        
        'Get the value without leading and trailing spaces (in UPPER CASE) from the Sentinel Cell
        'Test for the 'End Sentinel' ('Finished' CASE INSENSITIVE)
        'Exit if the 'End Sentinel' contains the SPECIAL VALUE
        sValue = UCase(Trim(Sheets(sSheetNAME).Range(sSentinelCELL).Value))
        If sValue = "FINISHED" Then
          bNeedMore = False
        End If
        
      Wend
      
      'Close the userform
      Call CloseUserFormMsgBox
      
    End Sub

    Lewis
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Re: msgbox disappear until right value entered

    Quote Originally Posted by LJMetzger View Post
    Hi biznez,

    Try the attached sample workbook which should help you get started. It displays a 'Faux' MsgBox that disappears when cell 'A1' contains 'Finished'.

    You don't have to use my UserForm, you can use your own. The UserForm has to be opened 'NonModally'
    UserForm1.Show False
    
    'or
    
    UserForm1.Show vbModeless
    The code that does the heavy lifting follows:
    Option Explicit
    
    #If VBA7 And Win64 Then
        ' 64 bit Excel
        'The following line is supposed to be RED in 32 bit Excel
        Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    #Else
        ' 32 bit Excel
        Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    #End If
    
    Sub DisplayUserFormAndWaitUntilFinishedIsInCellA1()
    
      Const sSheetNAME = "Main"
      Const sSentinelCELL = "A1"
      Const bMessageBold = True
    
      Dim i As Integer
      
      Dim bNeedMore As Boolean
      
      Dim sData As String
      Dim sValue As String
      
      
      'Initialize the "Custom Message Box' and it's attributes
      Call UseUserFormMsgBox
      Call SetUserFormMsgBoxMessageAttributes("Arial", 16, bMessageBold, vbBlue)
      
      'Display a Message in the Message Box
      sData = "Waiting for 'Finished' to appear in Cell 'A1'"
      Call DisplayUserFormMsgBoxMessageWithRefresh(sData)
      
      bNeedMore = True
      While bNeedMore = True
        
        'Allow Excel to do other things
        DoEvents
        
        'Make the application dormant most of the time
        Sleep 250
        
        'Get the value without leading and trailing spaces (in UPPER CASE) from the Sentinel Cell
        'Test for the 'End Sentinel' ('Finished' CASE INSENSITIVE)
        'Exit if the 'End Sentinel' contains the SPECIAL VALUE
        sValue = UCase(Trim(Sheets(sSheetNAME).Range(sSentinelCELL).Value))
        If sValue = "FINISHED" Then
          bNeedMore = False
        End If
        
      Wend
      
      'Close the userform
      Call CloseUserFormMsgBox
      
    End Sub

    Lewis
    Thanks LJMetzger ...ill look into this

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: msgbox disappear until right value entered

    I would think it would be easier to just set the UserForm ShowModal property to false, which will allow work to be perfomed on the sheet while the userform is still visible. Then trigger an unloading of the userform by worksheet_change event when A1 = Finished.

+ 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. [SOLVED] MSGBOX only if valid time is entered in a cell
    By sahdev in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2013, 04:02 PM
  2. [SOLVED] MsgBox if data entered in range is not numeric
    By kbka in forum Excel General
    Replies: 5
    Last Post: 11-19-2012, 08:35 AM
  3. Cant get MSGBOX to disappear after clicking on the OK button.
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-11-2012, 09:59 AM
  4. Entered Space in MsgBox
    By eddykk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2009, 02:28 AM
  5. Tabstrip tabs entered programmatically disappear after form unload
    By cumchee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-21-2005, 05:06 PM

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