You are on page 1of 1

5/14/2021 Forcing Input to Uppercase (Microsoft Excel)

Forcing Input to Uppercase


by Allen Wyatt 57
(last updated March 22, 2021)

If you are developing a worksheet for others to use, you may want them to always enter information in uppercase. Excel provides a worksheet
function that allows you to convert information to uppercase, but it doesn't apply as people are actually entering information. For instance, if
someone enters information in cell B6, then the worksheet function can't be used for converting the information in B6 to uppercase.
Instead, you must use a macro to do the changing for you. When programming in VBA, you can force Excel to run a particular macro whenever
anything is changed in a worksheet cell. The following macro can be used to convert all worksheet input to uppercase:

Private Sub Worksheet_Change(ByVal Target As Range)


If Target.HasFormula Then Exit Sub
Application.EnableEvents = False
Target = UCase(Target.Cells(1))
Application.EnableEvents = True
End Sub

For the macro to work, however, it must be entered in a specific place. Follow these steps to place the macro:
1. Display the VBA Editor by pressing Alt+F11.
2. In the Project window, at the left side of the Editor, double-click on the name of the worksheet you are using. (You may need to first open the
VBAProject folder, and then open the Microsoft Excel Objects folder under it.)
3. In the code window for the worksheet, paste the above macro.
4. Close the VBA Editor.
Now anything (except formulas) that are entered into any cell of the worksheet will be automatically converted to uppercase. If you don't want
everything converted, but only cells in a particular area of the worksheet, you can modify the macro slightly:

Private Sub Worksheet_Change(ByVal Target As Range)


If Not (Application.Intersect(Target, Range("A1:B10")) _
Is Nothing) Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End If
End Sub

In this particular example, only text entered in cells A1:B10 will be converted; everything else will be left as entered. If you need to have a different
range converted, specify that range in the second line of the macro.
Note:
If you would like to know how to use the macros described on this page (or on any other page on
the ExcelTipssites), I've prepared a special page that includes helpful information. Click here to open that
special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9813) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and
Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Forcing Input to Uppercase.

https://excelribbon.tips.net/T009813_Forcing_Input_to_Uppercase.html 1/1

You might also like