Always upper case

SimonHughes

Well-known Member
Joined
Sep 16, 2009
Messages
507
Office Version
  1. 365
Platform
  1. Windows
Hello, is it possible to format cells so the result is always upper case even if entered as lower case?

I am using MS365, TIA.
 
Sure. But it requires VBA.

If you are open to VBA, just let us know what range you want to apply it to, and we can give you the code for that.
Hi Joe,

The range is C10 to AG20 on 12 sheets (January through to December). I guess I would need to paste the code into all sheets?
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
This code should do the whole sheet even if the data is pasted in bulk from somewhere else
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
For Each cell In Target
    cell.Value = UCase(cell.Value)
Next cell
End Sub
Hi Efan, thanks for the response, I am going to see what Joe has said in reply to my answer,
 
Upvote 0
Right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this code in the VB Editor that opens (the code MUST be placed in this Sheet module in order to work automatically).

This will make everything in columns A-C upper case, though the range can be changed to work for any range you want.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
   
    Set rng = Intersect(Target, Range("A:C"))
   
    If rng Is Nothing Then Exit Sub
   
    Application.EnableEvents = False
   
    For Each cell In rng
        cell.Value = UCase(cell.Value)
    Next cell
   
    Application.EnableEvents = True
       
End Sub
Hi Joe, Job done, I changed the range to suit and pasted it into each sheet individually. Interested to see if there is a whole workbook function though - many thanks.
 
Upvote 0
Hi Joe, Job done, I changed the range to suit and pasted it into each sheet individually. Interested to see if there is a whole workbook function though - many thanks.
Yes, if you want the same thing to happen in every sheet, there is a way to just add the code in one place.

The code needs to be placed in the "ThisWorkbook" module in VBA, as shown here (open the VB Project Explorer if you do not see this):
1691101342774.png


And then we just need to make a few slight adjustments to the code, so it looks like this:
VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
    
    Set rng = Intersect(Target, Sh.Range("C10:AG20"))
    
    If rng Is Nothing Then Exit Sub
    
    Application.EnableEvents = False
    
    For Each cell In rng
        cell.Value = UCase(cell.Value)
    Next cell
    
    Application.EnableEvents = True
        
End Sub
That should do what you want to every sheet in your workbook.
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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