+ Reply to Thread
Results 1 to 2 of 2

Msgbox - when cell is empty

Hybrid View

KA_Analyst Msgbox - when cell is empty 07-13-2007, 09:43 AM
davesexcel maybe placing the msgbox... 07-15-2007, 04:36 PM
  1. #1
    Registered User
    Join Date
    06-22-2007
    Posts
    42

    Msgbox - when cell is empty

    I have a Data Input form and have put the following code in but if I miss out a field, it brings up my dialogue box saying you have missed this field but still populates the backing data sheet. Can anyone help me with the correct coding. Thanks in advance

     'Transfer the name
        Cells(NextRow, 1) = TraineeName.Text
             
        'clear controls for next entry
            
        TraineeName.Text = ""
        OptionUnknown = True
        TraineeName.SetFocus
        
        'make sure a name is entered
        If TraineeName.Text = "" Then
        MsgBox "Please enter name"
        Exit Sub    
        End If
        
        'Transfer the team
        Cells(NextRow, 2) = Team.Text
              
        'clear controls for next entry
        Team.Text = ""
        OptionUnknown = True
        Team.SetFocus
        
        'make sure a team is entered
        If Team.Text = "" Then
        MsgBox "Please enter team"
        Exit Sub    
        End If

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    maybe placing the msgbox before anything else in the code would work, therefore if data was missed the macro will exit before entering other data

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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