textbox empty - show message box

cnu nagula

Board Regular
Joined
Aug 28, 2008
Messages
83
Dear Friends,

i have userform with textboxes and commandbox.

i have 8 texboxes and 1 combobox.

i need a code to watch all textboxes are not empty, when i click combobox1. if any textbox is empty, a message is to popup, " your data in textbox? is not entered" i mean in a particular textbox

please help in this regards
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Something like this perhaps.
Code:
Private Sub CommandButton1_ Click()
Dim ctl As MSForms.Control

      For Each ctl In Me.Controls

         If TypeName(ctl) ="TextBox" Then
              If ctl.Value ="" Then
                    MsgBox ctl.Value & " empty, please enter something"
                     ctl.SetFocus
                      Exit Sub
              End If
          End If
      Next ctl
End Sub
 
Upvote 0
There is the simple Beep I suppose.

Though I would have thought that would be more appropriate when the user exits a textbox they've left empty.

That could be done using the Exit event of each textbox.

If you only have a few textboxes you can just duplicate the same code for each one, changing names appropriately.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,473
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top