vba control/check comboboxes/textboxes are empty or not

DB73

Board Regular
Joined
Jun 7, 2022
Messages
102
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2010
  6. 2007
Platform
  1. Windows
  2. Mobile
  3. Web
Ive made a form with several comboboxes en textboxes
if i populate these i let a "command button"write the text/value to my dumpstats sheet.
but sometimes i forget to populate 1 of these boxes.

is it possible to add some vba to that command button, before it sends all value to the dumpstats sheet, too check if 1 or more of the boxes are empty and then color the empty red so i can fill them in.
after completion to let it write to my dumpstats sheet.

at first i made it just with a message boxes, thats shows "everyting filled in correctly ?", but that isnt actulay checking and sometime is just say yes , and then i get some faults.

thanks in advance
 
Dave
if every cb is filled in then the data goes to my dumpstats sheet
my solution did not use any of the controls events - when you complete all required controls the function will return True to allow your code to submit the data.

If you want to change the backcolor from Red to whatever color as you enter data then you will need to do that in change event like that shown by @Anthony47 or you could create a common code for all events like this

place in Userform code page
VBA Code:
Sub SetBackColor(ByVal objControl As Control)
    With objControl
        .BackColor = IIf(Len(.Value) > 0, vbWhite, vbRed)
    End With
End Sub

which you call from each control change event
VBA Code:
Private Sub ComboBox1_Change()
    SetBackColor Me.ComboBox1
End Sub

Dave
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

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