Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Results in TextBoxes, ONLY if All TextBoxes have Data in them
I have a total of 8 Textboxes and 1 ComboBox in a UserForm. Textboxes 1-4
show calculation results that are dependent on Textboxes 5-8 and the ComboBox. I am currently using the Change Event in Textboxes 5-8 and the ComboBox for an instant calculation for the user to see. My question is how do I get Textboxes 1-4 to be blank if any of the Textboxes 5-8 or the Combobox is blank. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Results in TextBoxes, ONLY if All TextBoxes have Data in them
Try something like this
Function checkBoxes(w, x, y, z) Dim tbEmpty As Boolean tbEmpty = False If w = "" Then tbEmpty = True If x = "" Then tbEmpty = True If y = "" Then tbEmpty = True If z = "" Then tbEmpty = True If tbEmpty = True Then checkBoxes = "True" Else checkBoxes = "False" End Function Private Sub CommandButton1_Click() Dim txt1, txt2, txt3, txt4 As String txt1 = Trim(TextBox5.Text) txt2 = Trim(TextBox6.Text) txt3 = Trim(TextBox7.Text) txt4 = Trim(TextBox8.Text) If checkBoxes(txt1, txt2, txt3, txt4) = "True" Then Exit Sub 'calculations End Sub -- -John Please rate when your question is answered to help us and others know what is helpful. "RyanH" wrote: I have a total of 8 Textboxes and 1 ComboBox in a UserForm. Textboxes 1-4 show calculation results that are dependent on Textboxes 5-8 and the ComboBox. I am currently using the Change Event in Textboxes 5-8 and the ComboBox for an instant calculation for the user to see. My question is how do I get Textboxes 1-4 to be blank if any of the Textboxes 5-8 or the Combobox is blank. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Results in TextBoxes, ONLY if All TextBoxes have Data in
I appreciate the fast response John! I'm not sure if this is what I need. I
think your example requires CheckBoxes and/or a Command Button Click Event. I need the Values of TextBoxes 1-4 to be "" if all the TextBoxes 5-8 and the ComboBox are blank. "John Bundy" wrote: Try something like this Function checkBoxes(w, x, y, z) Dim tbEmpty As Boolean tbEmpty = False If w = "" Then tbEmpty = True If x = "" Then tbEmpty = True If y = "" Then tbEmpty = True If z = "" Then tbEmpty = True If tbEmpty = True Then checkBoxes = "True" Else checkBoxes = "False" End Function Private Sub CommandButton1_Click() Dim txt1, txt2, txt3, txt4 As String txt1 = Trim(TextBox5.Text) txt2 = Trim(TextBox6.Text) txt3 = Trim(TextBox7.Text) txt4 = Trim(TextBox8.Text) If checkBoxes(txt1, txt2, txt3, txt4) = "True" Then Exit Sub 'calculations End Sub -- -John Please rate when your question is answered to help us and others know what is helpful. "RyanH" wrote: I have a total of 8 Textboxes and 1 ComboBox in a UserForm. Textboxes 1-4 show calculation results that are dependent on Textboxes 5-8 and the ComboBox. I am currently using the Change Event in Textboxes 5-8 and the ComboBox for an instant calculation for the user to see. My question is how do I get Textboxes 1-4 to be blank if any of the Textboxes 5-8 or the Combobox is blank. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Results in TextBoxes, ONLY if All TextBoxes have Data in
I just named it checkboxes, as in check the textboxes. I did forget the
combobox. This should cover you, but I did leave it as a button click event, put the function outside of course but put the code inside the button click event inside whatever event you are using. Function checkBoxes(v, w, x, y, z) Dim tbEmpty As Boolean tbEmpty = False If w = "" Then tbEmpty = True If x = "" Then tbEmpty = True If y = "" Then tbEmpty = True If z = "" Then tbEmpty = True If tbEmpty = True Then checkBoxes = "True" Else checkBoxes = "False" End Function Private Sub CommandButton1_Click() Dim txt1, txt2, txt3, txt4, cmb1 As String txt1 = Trim(TextBox5.Text) txt2 = Trim(TextBox6.Text) txt3 = Trim(TextBox7.Text) txt4 = Trim(TextBox8.Text) cmb1 = Trim(ComboBox1.Text) If checkBoxes(cmb1, txt1, txt2, txt3, txt4) = "True" Then TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" End If End Sub -- -John Please rate when your question is answered to help us and others know what is helpful. "RyanH" wrote: I appreciate the fast response John! I'm not sure if this is what I need. I think your example requires CheckBoxes and/or a Command Button Click Event. I need the Values of TextBoxes 1-4 to be "" if all the TextBoxes 5-8 and the ComboBox are blank. "John Bundy" wrote: Try something like this Function checkBoxes(w, x, y, z) Dim tbEmpty As Boolean tbEmpty = False If w = "" Then tbEmpty = True If x = "" Then tbEmpty = True If y = "" Then tbEmpty = True If z = "" Then tbEmpty = True If tbEmpty = True Then checkBoxes = "True" Else checkBoxes = "False" End Function Private Sub CommandButton1_Click() Dim txt1, txt2, txt3, txt4 As String txt1 = Trim(TextBox5.Text) txt2 = Trim(TextBox6.Text) txt3 = Trim(TextBox7.Text) txt4 = Trim(TextBox8.Text) If checkBoxes(txt1, txt2, txt3, txt4) = "True" Then Exit Sub 'calculations End Sub -- -John Please rate when your question is answered to help us and others know what is helpful. "RyanH" wrote: I have a total of 8 Textboxes and 1 ComboBox in a UserForm. Textboxes 1-4 show calculation results that are dependent on Textboxes 5-8 and the ComboBox. I am currently using the Change Event in Textboxes 5-8 and the ComboBox for an instant calculation for the user to see. My question is how do I get Textboxes 1-4 to be blank if any of the Textboxes 5-8 or the Combobox is blank. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need help w/ userform with 12 textboxes with data going into colum | Excel Discussion (Misc queries) | |||
How not to show zero in textboxes? | Excel Programming | |||
Combining data in multiple textboxes | Excel Programming | |||
Transferring cell data to textboxes | Excel Programming | |||
searching for a combobox.value and filling in textboxes from results | Excel Programming |