How Text String to Upper, Lower, or Proper Case in Excel VBA

  Excel Interview Q&A

Learn how to force text string for upper, lower or Proper case in Excel today? Or appropriate cases in your Excel 2013/2016 via Excel formula or data validation. How to convert text to upper, lower or proper case in Excel.

Assuming that you want to force the text string to upper case when you type the word in a cell, and how to do it. You can use an Excel function in the data validation feature to achieve this. Just do the following steps:

Step 1: Visit to the data tab, click on the data validation command under the Data Tools group. Then click on the data validation menu from the drop down menu list. Then the data validation window will appear.
Step 2: In the Data Validation dialog box, switch to the More Settings tab, and click Allow drop down list and choose Custom value from the drop down menu list.
Step 3: Then type the following formula in the Data Validation dialog box in the Formula text box.

Pay attention:

If you want to convert the text string to upper case, type the following formula:

=EXACT(UPPER(B1),B1)

If you want to convert the text string to lower case, just use the following formula:

=EXACT(LOWER(B1),B1)

If you want to convert the text string to ProperCase, just use the following formula:

=EXACT(PROPER(B1),B1)

Step 4: Then you need to switch to the error alert tab in the data validation dialog box. And select the stop value from the style drop down list box, and type some error message under the error message text box. Then click on the Ok button.

Step 5: If you take effect, you can try to enter a text string in cell B1 to verify this.

To better understand follow the snapshot 

Force Text String to Upper,Lower, or Proper Case in Excel

Force Text String to Upper,Lower, or Proper Case in Excel

Force Text String to Upper,Lower, or Proper Case in Excel VBA

Excel VBA macro to get you the same result of forcing text string in upper, lower or proper cases in worksheet. Just do the following steps:

Step 1: Open your Excel workbook and then click the “Visual Basic” command under the DEVELOPER tab or press the shortcut “ALT + F11”.
Step 2: Then the “Visual Basic Editor” window will appear.
Step 3: Select your project worksheet from the left project explorer, and double click on it to open the code window, and copy and paste the following VBA code into it.

For upper case:

Private Sub Worksheet_Change(ByVal Target As Range)

Target.Value = VBA.UCase(Target.Value)

End Sub

For Lower Case:

Private Sub Worksheet_Change(ByVal Target As Range)

Target.Value = VBA. LCase (Target.Value)

End Sub

For Proper Case:

Private Sub Worksheet_Change(ByVal Target As Range)

Target.Value = VBA. LCase (Target.Value)

End Sub

Step 4: Save and close the current VBA window. And then you can try to enter a text string to verify it. When you type a word it is short or appropriate, and it will change it to uppercase.

Force Text String to Upper,Lower, or Proper Case in Excel VBA

Force Text String to Upper,Lower, or Proper Case in Excel VBA

LEAVE A COMMENT