ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Apples or pears (https://www.excelbanter.com/excel-programming/323588-apples-pears.html)

gregork

Apples or pears
 
Hi could someone show me the correct way of writing this code:

If Me.TextBox1.Text = "Apples" or "pears" Then
Unload Me
UserForm4.Show
End If

thanks
GK



Leo Heuser[_3_]

Apples or pears
 
Hi

Try this one:

If Ucase(Me.TextBox1.Text) = "APPLES" Or _
Ucase(Me.TextBox1.Text) = "PEARS" Then
Unload Me
UserForm4.Show
End If

The use of Ucase() means, that the user can
enter any combination of upper- and/or lower case
in the text box.

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"gregork" skrev i en meddelelse
...
Hi could someone show me the correct way of writing this code:

If Me.TextBox1.Text = "Apples" or "pears" Then
Unload Me
UserForm4.Show
End If

thanks
GK





gregork

Apples or pears
 
Thanks for the reply. Can't get it to work though. Not sure why?

cheers
GK

"Leo Heuser" wrote in message
...
Hi

Try this one:

If Ucase(Me.TextBox1.Text) = "APPLES" Or _
Ucase(Me.TextBox1.Text) = "PEARS" Then
Unload Me
UserForm4.Show
End If

The use of Ucase() means, that the user can
enter any combination of upper- and/or lower case
in the text box.

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"gregork" skrev i en meddelelse
...
Hi could someone show me the correct way of writing this code:

If Me.TextBox1.Text = "Apples" or "pears" Then
Unload Me
UserForm4.Show
End If

thanks
GK







Tom Ogilvy

Apples or pears
 
If instr(1,Me.Textbox1.Text,"apples",vbTextcompare) 0 or _
instr(1,Me.Textbox1.Text,"pears",vbTextcompare) 0 then
Unload Me
Userform4.Show
End if

--
Regards,
Tom Ogilvy


"Leo Heuser" wrote in message
...
Hi

Try this one:

If Ucase(Me.TextBox1.Text) = "APPLES" Or _
Ucase(Me.TextBox1.Text) = "PEARS" Then
Unload Me
UserForm4.Show
End If

The use of Ucase() means, that the user can
enter any combination of upper- and/or lower case
in the text box.

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"gregork" skrev i en meddelelse
...
Hi could someone show me the correct way of writing this code:

If Me.TextBox1.Text = "Apples" or "pears" Then
Unload Me
UserForm4.Show
End If

thanks
GK







gregork

Apples or pears
 
Works perfectly thanks Tom

Regards
GK

"Tom Ogilvy" wrote in message
...
If instr(1,Me.Textbox1.Text,"apples",vbTextcompare) 0 or _
instr(1,Me.Textbox1.Text,"pears",vbTextcompare) 0 then
Unload Me
Userform4.Show
End if

--
Regards,
Tom Ogilvy


"Leo Heuser" wrote in message
...
Hi

Try this one:

If Ucase(Me.TextBox1.Text) = "APPLES" Or _
Ucase(Me.TextBox1.Text) = "PEARS" Then
Unload Me
UserForm4.Show
End If

The use of Ucase() means, that the user can
enter any combination of upper- and/or lower case
in the text box.

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"gregork" skrev i en meddelelse
...
Hi could someone show me the correct way of writing this code:

If Me.TextBox1.Text = "Apples" or "pears" Then
Unload Me
UserForm4.Show
End If

thanks
GK










All times are GMT +1. The time now is 11:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com