Want the command button to check if any of the many textboxes in a userform are empty.
If empty, Want the macro to
- setfocus on that textbox
- Message box (pls enter the value)
tried this
Problem :![]()
Private Sub CommandButton1_Click() Dim ctl As Control For Each ctl In Controls If TypeOf ctl Is TextBox Then If IsNull(ctl.Value) = True Then ctl.SetFocus GoTo lastline Exit Sub End If End If Next lastline: MsgBox "Data is required" End Sub
Doesn't setfocus the empty textbox
Bookmarks