VBA function to make text uppercase

Asked

Viewed 9,083 times

-3

Good afternoon. How to capitalize the spans of just a few cells of a form mounted on an excel sheet? Numeric and e-mail field cells should not be altered. I only found formulas and functions for isolated cells, columns or the entire spreadsheet, but precise for some alternating cells in several columns and rows.

  • Place an image with your form to help us understand what you have and what you want to get. Your explanation is very confusing!

  • 1

    The formula =MAIÚSCULA() won’t solve your problem?

  • No, because I need to capitalize the text on the same cell where it’s typed.

  • I gave you two answers but no feedback. Contribute to the community by following your questions as well.

2 answers

0

Via VBA, you can associate the following code with the`Change`` event in the Sheets module:

Private Sub Worksheet_Change(ByVal Target As Range)

    On Error Resume Next
        If Not Intersect(Target, Range("A1:B20")) Is Nothing Then
            Application.EnableEvents = False
            Target = UCase(Target)
            Application.EnableEvents = True
            End If
    On Error GoTo 0

End Sub

0

You can force the user to type only in uppercase letters via Data Validation. Select the range and click Data Validation. Under 'Allow', select the 'Custom' option and in the 'Formula' field type the function =EXATO(A1;MAIÚSCULA(A1)).

Validação de textos em letras maiúsculas

(if your Excel is in English, just copy the text from the image)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.