How To Convert Text to Upper Cases(Using VBA) in Excel

,

This post will show you how to switch from lower case to upper case in Excel. and I am going to show you two different ways of converting text to upper cases using formula or VBA macro in Excel 2013,Excel 2016,Excel 2019 or Excel 365.

If you are familiar using Microsoft Word and you can easily change the text to Upper, Lower, and Title cases using “Change Case” command. But this button is not available in Microsoft Excel. but you can still easily accomplish this in Microsoft Excel as well.

Assume that you have a data set where you want to change all text to Upper cases, you can do it through two methods below.

Convert Text to Upper Cases using Excel Formula or Function


I have a list of few peoples with their names(first name and last name), and I want to change the case of First Name fields to all upper case. To do this, you can use Upper function of Microsoft Excel. just do the following steps:

Step1: you need to insert a blank column between the both First Name and Last Name columns. Just click column B and right click it, and then click on insert from the drop-down menu list. Then a newly column should be created next to Column A.

convert text to upper cases1

Step2: Enter the below UPPER formula in Cell B2 and press Enter key.

=UPPER(A2) 

convert text to upper cases1

Step3: then you need to copy the formula into the remaining cells. or just drag the AutoFill handler in Cell B2 down to other cells to apply this formula.

convert text to upper cases1

You can see that there are 2 columns with the same values in your data sets and at this time you can hide the original one.

Note: you can not delete the values from column A, because Column B results depends on Column A. You’d better to hide the actual column or column A.

Convert Text to Upper Cases using VBA Code


If you want to quickly convert or change text string to uppercase every in your selected range in Excel, and you can use the following short VBA code to achieve the result. Just do the following steps:

Step 1: On current visible worksheet, right click on sheet name tab to load Sheet management menu. Select View CodeMicrosoft Visual Basic for Applications window pops up.

hide every other row1

Or you can enter Microsoft Visual Basic for Applications window via Developer->Visual Basic. You can also press Alt + F11 keys simultaneously to open it.

How to Remove All Extra Spaces and Keep Only One Between Words 5

Step 2: In Microsoft Visual Basic for Applications window, enter below code:

Sub changeUpperCases()
  Dim myRange As Range
  Dim myworkRange As Range
  On Error Resume Next
  myTitle = "Convert Text To Upper Cases"
  Set myworkRange = Application.Selection
  Set myworkRange = Application.InputBox("Select one range that you want to convert to Upper case ", myTitle, myworkRange.Address, Type:=8)
  For Each myRange In myworkRange
    myRange.Value = VBA.UCase(myRange.Value)
  Next
End Sub
convert text to upper cases1

Step 3: Save code, quit Microsoft Visual Basic for Applications.

Step 4: Click Developer->Macros to run Macro.

Highlight All Non-Blank Cells 13

Step 5: Select the Macro Name ‘changeUpperCases’from the Macro window and click Run.

convert text to upper cases1

Step 6: you need to select one range that you wish to convert text string to uppercase, such as: $A$1:$B$10, then clicking Ok button.

convert text to upper cases1

Step 7: Once you have clicked “Ok” button in the step 5, it will go through each row and convert text string to uppercase in your selected range. see the below result:

convert text to upper cases1

Note: when you have a VBA Macro in your workbook, and you need to save it as a Macro-enabled file with the .XLSM extension in Excel. Since there are any changes made by the VBA Macro are irreversible, and you’d better to make a backup copy of your workbook or worksheet firstly and then run the VBA code.

You can also copy the contents from Microsoft Excel and then paste them into Microsoft Word. And using the desire Change Case style. And then copy the contents from Microsoft Word and then replace them into your current worksheet.

Related Functions


  • Excel UPPER function
    The Excel UPPER function converts all characters in text string to uppercase.The UPPER function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the UPPER function is as below:= UPPER (text)…