Convert Small Letters into Uppercase for Some Columns

Follow by Email
Facebook
Facebook
Google+
http://www.exceltip.com/excel-macros-and-vba/convert-small-letters-into-uppercase.html
SHARE




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

Please follow and like us:
0


Leave a Reply

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

To avoid automated spam,Please enter the value *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>