DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

How to Convert Selection to UPPERCASE using Macros in Excel?

In this article, we are going to see how to convert the selected range to uppercase using Macros in Excel Office 365. Macros and VBA is an interesting area in Excel. If you want to know how to do this task on your Excel worksheet, then follow the below instructions given in this article.

Convert Selection to Uppercase using Macros:

Kindly, follow the below steps to convert the selection to uppercase using the Macros concept.

  • In the below screenshot, we have shown you the input selection range from B1:B5. Let’s convert them into UPPERCASE with the help of macros.

Example
Example

  • On the Developer Tab, select the Visual Basic option under the Code section.

Select Visual Basic option
Select the Visual Basic option

  • Then you need to copy and paste the code given below.

VBA code to convert selection to uppercase using Macros

Sub ConvertToUpperCase()

Dim rng As Range

For Each rng In Selection

If Application.WorksheetFunction.IsText(rng) Then

rng.Value = UCase(rng)

End If

Next

End Sub

  • You need to save the code by selecting it. Then close the window.

Enter the code
Enter the code

  • You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.

Choose the Macros option
Choose the Macros option

  • You need to make sure that your macro is selected and click the Run button.

Click the Run button
Click the Run button

  • At last, you can get the output as shown in the below image. The selection range has been converted to uppercase.

Output
Output

Sum-Up:

In the above article, you can clearly understand the steps to convert selection to uppercase using Macros in Excel Office 365. Leave your worthwhile feedback with us in the below comment section. Thanks for visiting Geek Excel. Keep Learning!

Keep Reading:

Top comments (0)