Hello Excel gurus!
As the title suggests, is there a way on how I can compress lines and lines of logical/conditional statements in an IF-ELSE statement? I have been searching for an applicable and most effective approach but they offer solutions a bit far from what I want to achieve.
For example.
I want to check if multiple Textboxes in a userform hold values or simply empty, and then execute some action.
If Me.TextBox1.Text = "" Or Me.TextBox2.Text Or Me.TextBox3.Text Or Me.TextBox1.Text = "" Or Me.TextBox2.Text Or Me.TextBox3.Text Or Me.TextBox4.Text = "" Or Me.TextBox5.Text Or Me.TextBox6.Text Or Me.TextBox7.Text = "" Or Me.TextBox8.Text Or Me.TextBox9.Text Or Me.TextBox1.Text = "" Or Me.TextBox10.Text Or Me.TextBox11.Text Or Me.TextBox12.Text = "" Or Me.TextBox13.Text Or Me.TextBox14.Text Then'do something
else'do something
End If
I am using the For...Next looping statement in some of part the program, but am not able to apply it in this instance.
Below is the sample of my code with looping statement.
For i = 1 to 14Me.Controls("TextBox" & i).Value = Me.Controls("Label" & i).Caption
Next
Hope you can give me a shorter way to do this.
Thanks in advance.
Bookmarks