av8tordude
11-08-2012, 10:11 AM
I have 13 textboxes in a userform. I want to check if at least 1 textbox has a value. If at least 1 textbox has a value, then do nothing. If neither textboxes has a value then display a msgbox only once. I'm using this code below, but it displays the msgbox for each textbox that is empty and displays the msgbox even if all the textboxes are filled...
Private Sub Enter_Click()
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If InStr(1, Ctrl.Name, "TextBox") > 0 Then
MsgBox "No Value entered" ' Display the text
End If
Next
End Sub
Private Sub Enter_Click()
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If InStr(1, Ctrl.Name, "TextBox") > 0 Then
MsgBox "No Value entered" ' Display the text
End If
Next
End Sub