Convert Small Letters into Uppercase for Some Columns

How to Convert Small Letters into Uppercase Letters for few columns using VBA in Microsoft Excel

 

In this article we will learn how to convert text into capital letters in specific columns (not all cells) using VBA code.

Question): I want code that will replace the text enter in small letters into upper case in some columns (not all of them).

Say I do not want the code to run on columns 4, 6, 9, 12, & 13 i.e. if any text is entered in these columns then the code will not be triggered.

In order to get the upper case letters as you type in small letters; we need to follow the below steps to launch VB editor

  • Click on Developer tab
  • From Code group, select Visual Basic

 

img1

 

Copy the following code in Sheet module

 

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Column = 4 Or Target.Column = 6 Or Target.Column = 9 _

Or Target.Column = 12 Or Target.Column = 13 Then Exit Sub

On Error GoTo ErrHandler

Application.EnableEvents = False

Target.Formula = UCase(Target.Formula)

ErrHandler:

Application.EnableEvents = True

End Sub

img2

 

  • The code will work in sheet1 only as the code is entered in sheet1
  • The code will automatically replace the small letter typed by mistake or in ignorance immediately into upper case letter in all columns except 4, 6, 9, 12, & 13.

 

In this way, we can convert text to caps in specific columns using VBA code.

 

image 7

Download - How To Convert Small Letters Into Uppercase Letters - xlsm

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.