VBA Code to force UpperCase in cells.

StuartUK

New Member
Joined
May 18, 2011
Messages
4
Morning all :)
Hopefully a nice easy one.....

When a user enters letters into a cell, i want it so that if they forget to type in caps, it automatically changes the text to UPPERCASE
specifically between this range: B5:BK16

I had the code which i found looking through forums, but deleted the code and cant remember it! doh! :(
any help appreciated :)
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You could also use Data Validation to try to force upper case entry. For example in A1, Custom Data Validation formula of:

=EXACT(A1,UPPER(A1))

Neither the Data Validation method nor the vba method is foolproof.

Data Validation can be 'defeated' if the user pastes values since the paste also removes the existing Data Validation.

The vba is 'defeated' if the user does not enable macros.
 
Last edited:
Upvote 0
I did consider using Data Validation, but unfortunately people here seem to like cutting and pasting far too much :) but I've managed to get them to enable macro's whenever using this Workbook so I shouldn't have that problem.

is there a solution for that like converting an XLS file to an EXE or what??

Using a workaround for stopping all functionality if macro's aren't enabled works for me
 
Upvote 0
is there a solution for that like converting an XLS file to an EXE or what??:eeek:
I'm not sure about converting to an exe, that is not an area of expertise of mine.

It is not all that straight-forward, but it is possible to force users to enable macros. Search this forum and you should find several threads where this has been discussed. You would find many other suggestions/discussions about this at various other locations. For example, here are two:

http://www.vbaexpress.com/kb/getarticle.php?kb_id=578

http://answers.microsoft.com/en-us/office/forum/office_2007-customize/excel-guru-force-enable-macro-solution-seriously/cdf9885f-f4e3-4424-8fab-7adc541d1c6f
 
Upvote 0
I have a similar situation to the OP except that the data I need in upper case is obtained by vlookup formulae on the worksheet. The source data is in mixed case.

The coding given by Peter converts my data to upper case OK but it overwrites the vlookup formula with the upper case value. That effectively makes the worksheet a single use sheet as the vlookup formula is no longer there.

Can the coding be amended so that the underlying vlookup formula remains in place but the output is capitalized - or am I asking the impossible?
 
Upvote 0
I have a similar situation to the OP except that the data I need in upper case is obtained by vlookup formulae on the worksheet. The source data is in mixed case.

The coding given by Peter converts my data to upper case OK but it overwrites the vlookup formula with the upper case value. That effectively makes the worksheet a single use sheet as the vlookup formula is no longer there.

Can the coding be amended so that the underlying vlookup formula remains in place but the output is capitalized - or am I asking the impossible?
Can't you just wrap your formula with the UPPER function?

If you have this...

=YourFormula

then change it to this...

=UPPER(YourFormula)
 
Upvote 0
OMG - it's that simple!!

Thank you so much Rick - that's another little boost to my Excel understanding.
 
Upvote 0

Forum statistics

Threads
1,225,169
Messages
6,183,313
Members
453,155
Latest member
joncaxddd

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