Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Forcing Input to Uppercase.
by Allen Wyatt
(last updated October 11, 2014)
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 your 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) With Target If Not .HasFormula Then Application.EnableEvents = False .Value = UCase(.Value) Application.EnableEvents = True End If End With End Sub
For the macro to work, however, it must be entered in a specific place. Follow these steps to place the macro:
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.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9813) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Forcing Input to Uppercase.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
Want a really easy way to create a selection of a group of cells? Discover how to use the Extend key to make this task easier ...Discover More
When entering information in a worksheet, it is common to also note a date or time corresponding to the entry. There are ...Discover More
If you need to swap the contents of two cells in your worksheet, Excel provides a number of ways you can approach the task. ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.