Userform

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
I have a userform to fill in several textboxes.When there are blanco boxen then in textbox19 I receiVe the text : Yellow box must be filled.
The problem is that this text always appeard.

If TextBox1.Value = "" Then TextBox1.BackColor = vbYellow Else TextBox1.BackColor = vbWhite
If Textbox0.Value = "" Then Textbox0.BackColor = vbYellow Else Textbox0.BackColor = vbWhite
If TextBox8.Value = "" Then TextBox8.BackColor = vbYellow Else TextBox8.BackColor = vbWhite
If TextBox9.Value = "" Then TextBox9.BackColor = vbYellow Else TextBox9.BackColor = vbWhite
If TextBox7.Value = "" Then TextBox7.BackColor = vbYellow Else TextBox7.BackColor = vbWhite
'If TextBox10.Value = "" Then TextBox10.BackColor = vbYellow Else TextBox10.BackColor = vbWhite
If TextBox20.Value = "" Then TextBox20.BackColor = vbYellow Else TextBox20.BackColor = vbWhite
If Combobox4.Value = "" Then Combobox4.BackColor = vbYellow Else Combobox4.BackColor = vbWhite
If ComboBox5.Value = "" Then ComboBox5.BackColor = vbYellow Else ComboBox5.BackColor = vbWhite
TextBox19.Text = "Yellow box must be filled."

Someone have an idea what the reason can be ?
Many thanks in advance
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
What is the test that you would perform that would provide the text, what rules would be expected to make sure it dosen't appear
 
Upvote 0
Code:
Option ExplicitSub chngcolr90()




If TextBox1.Value = "" Then
    TextBox1.BackColor = vbYellow
Else
    TextBox1.BackColor = vbWhite
End If
    
If Textbox0.Value = "" Then
    Textbox0.BackColor = vbYellow
Else
    Textbox0.BackColor = vbWhite
End If


If TextBox8.Value = "" Then
    TextBox8.BackColor = vbYellow
Else
    TextBox8.BackColor = vbWhite
End If


If TextBox9.Value = "" Then
    TextBox9.BackColor = vbYellow
Else
    TextBox9.BackColor = vbWhite
End If


If TextBox7.Value = "" Then
    TextBox7.BackColor = vbYellow
Else
    TextBox7.BackColor = vbWhite
End If


'If TextBox10.Value = "" Then TextBox10.BackColor = vbYellow Else TextBox10.BackColor = vbWhite


If TextBox20.Value = "" Then
    TextBox20.BackColor = vbYellow
Else
    TextBox20.BackColor = vbWhite
End If


If Combobox4.Value = "" Then
    Combobox4.BackColor = vbYellow
Else
    Combobox4.BackColor = vbWhite
End If


If ComboBox5.Value = "" Then
    ComboBox5.BackColor = vbYellow
Else
    ComboBox5.BackColor = vbWhite
End If


'THIS NEXT LINE NEEDS TO BE IN AN "IF / THEN / ELSE" STATEMENT AS WELL OR IT WILL ALWAYS SHOW UP


TextBox19.Text = "Yellow box must be filled."


End Sub

You should consider placing the above code into an ARRAY to reduce the size of your macro.

Also, ALWAYS use OPTION EXPLICIT at the top of your macros - it will help you identify errors as you program.
 
Upvote 0

Forum statistics

Threads
1,203,674
Messages
6,056,679
Members
444,881
Latest member
Stu2407

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