Skip to main content

How to force text string to uppercase / lowercase / proper case in Excel?

In Excel, when you enter some letters or words into the cells, you want to force the text strings to uppercase even though you entered the lowercase or proper case letters and vice versa. Most of us may consider the Data Validation feature in Excel, with this function, we will get a warning when we don’t type the correct case of the text. In this article, I will introduce some interesting ways to force the text to uppercase, lowercase or proper case as you need.

Force the text strings to uppercase / lowercase / proper case with Data Validation

Force the text strings to uppercase / lowercase / proper case with VBA code

Change text to UPPERCASE/lowercase/Proper Case with Kutools for Excel good idea3


Data Validation is a powerful tool in Excel, it can help us to do many operations, with its help, we can also force the uppercase, lowercase or proper case of the text strings when typing, please do as follows:

1. Go to click Data > Data Validation > Data Validation, see screenshot:

doc-force-uppercase-1

2. In the Data Validation dialog, under the Settings tab, click the Allow drop down list and choose Custom option, then in the Formula text box, enter this formula =EXACT(UPPER(A1),A1), (A1 stands for a column that you will apply this feature, you can change it to your need ), see screenshot:

doc-force-uppercase-1

3. Then you can create an alert as you need, please click Error Alert tab, and select Stop from the Style drop down list, at the right corner of the Error message text box, enter your own warning message, see screenshot:

doc-force-uppercase-1

4. And then click OK to close the dialog, now when you enter the text string not in uppercase in column A, a warning box will pop out to remind you entering the uppercase letters.

doc-force-uppercase-1

Note:

If you need to force the text strings to lowercase or proper case, please apply the following formulas into the Data Validation in step 2.

Force to lowercase: =EXACT(LOWER(A1),A1);

Force to proper case: =EXACT(PROPER(A1),A1)


With the following VBA code, when you enter the lowercase words into a cell, the lowercase text will be changed to the uppercase letters automatically.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Then choose your used worksheet from the left Project Explorer, double click it to open the Module, and then copy and paste following VBA code into the blank Module:

VBA code: Force text string to uppercase

Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140603
Target.Value = VBA.UCase(Target.Value)
End Sub

doc-force-uppercase-1

3. Then save and close this code to return to the worksheet, now when you enter text string whenever it is lowercase or proper case, it will become uppercase after tapping the Enter key automatically.

Notes:

1. This code is applied to the whole worksheet.

2. If you cannot find the Project Explorer Pane in the window, you can click View > Project Explorer to open it.

3. To force the words lowercase or proper case, you can apply the following VBA code: (The procedure is the same as the above)

VBA code: Force text string to Lowercase

Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140603
Target.Value = VBA.LCase(Target.Value)
End Sub

VBA code: Force text string to proper case

Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140603
Target.Value = Application.WorksheetFunction.Proper(Target.Value)
End Sub

If you just want to change some specific texts into UPPERCASE, lowercase or Proper Case, you can apply the Change Case utility of Kutools for Excel to quickly get it done.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After free installing Kutools for Excel, please do as below:

1. Select the texts you want to change case and click Kutools > Text > Change Case. See screenshot:
doc change case 6

2. In the Change Case dialog, check the operation option as you need, and you can preview the result in the Preview pane. See screenshot:
doc change case 2

3. Click Ok or Apply and the texts have been change case.

 Change to UPPERCASE  Change to Proper Case  Change to Sentence case
 doc change case 3  doc change case 4 doc change case 5 

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Please suggest modifications in the VBA code to force the text strings to change to the desired format (Upper/Lower/Proper case) in selected/specified cells only rather than changing the Case of the text strings in the entire worksheet.
This comment was minimized by the moderator on the site
Hello, DS,
To apply the code to a specified range instead of entire worksheet, please apply the following code:
VBA code: Force text string to uppercase
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim SpecifiedRange As Range
    Set SpecifiedRange = Me.Range("A1:A10")
    If Not Intersect(Target, SpecifiedRange) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = VBA.UCase(Target.Value)
        Application.EnableEvents = True
    End If
End Sub


VBA code: Force text string to lowercase
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim SpecifiedRange As Range
    Set SpecifiedRange = Me.Range("A1:A10")
    If Not Intersect(Target, SpecifiedRange) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = VBA.LCase(Target.Value)
        Application.EnableEvents = True
    End If
End Sub


VBA code: Force text string to propercase
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim SpecifiedRange As Range
    Set SpecifiedRange = Me.Range("A1:A10")
    If Not Intersect(Target, SpecifiedRange) Is Nothing Then
        Application.EnableEvents = False
        Target.Value = Application.Proper(Target.Value)
        Application.EnableEvents = True
    End If
End Sub


Please have a try, thank you!
This comment was minimized by the moderator on the site
Use: On Error Resume Next

Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140603
On Error Resume Next
Target.Value = Application.WorksheetFunction.Proper(Target.Value)
End Sub
This comment was minimized by the moderator on the site
muchas gracias, sirvio enormemente estos codigos
This comment was minimized by the moderator on the site
This worked for me, however if you went to delete the contents of the cell then a "runtime error '13': type mismatch" came up

Any ideas?
This comment was minimized by the moderator on the site
i have the same problem. if you know how to deal with it please tell me!
This comment was minimized by the moderator on the site
Hello, which method you use will come up the errors?
This comment was minimized by the moderator on the site
Like your VBA solution, but how could I limit it to a single column and format other columns differently, e.g., columns A and C force uppercase, column B force proper case?
This comment was minimized by the moderator on the site
I do not know which VBA can handle your job (some columns in uppercase, some in proper case), but the data validation can solve it, why do not use it?
This comment was minimized by the moderator on the site
thanks for the macro to convert all entries to capital letters, but is there something i need to do to stop the macro from crashing excel every fe minutes? Appreciate the help!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations