Case Format VBA

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
173
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm using a form where users can enter a code in a text box. I would like this code (can be letters or numbers, or both) to be in Upper Case only. I'm using the below code at the moment:

Code:
If txtNewPortfolio.Value = LCase(txtNewPortfolio.Text) Then
frmError.Show

I've found that this code only works where the code is completely in Lower case (eg. "code"), but does not work when any letter is in Upper case (eg. "Code").

How can I manipulate this code to run form "frmError" if any letter enetered is in Lower case?

Thanks.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Code:
If [B]LCase[/B](txtNewPortfolio.Value) = LCase(txtNewPortfolio.Text) Then
frmError.Show
 
Upvote 0
Thanks wigi, but now it's bringing up the form for either Upper and Lower case letters.
 
Upvote 0
Then, please give a better explanation about:

- the 2 parts in the IF (which is the "code", what is the other (is that a range on a sheet?)
- the exact logic for the UF to show.
 
Upvote 0
Sorry, let me try and explain it better.

Quite simply... if any letter enter by the user in the text box (txtNewPortfolio) is in Lower case, then show the user form (frmError).

Right now, the code that I have...

Code:
If txtNewPortfolio.Value = LCase(txtNewPortfolio.Text) Then
frmError.Show

...will not show the form (frmError) as long as there is at least one Upper Case letter present (eg. Test).

I would like the form to show if any letter entered by the user is in Lower Case.
 
Upvote 0
Code:
If txtNewPortfolio.Text <> UCase(txtNewPortfolio.Text) Then frmError.Show
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

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