Mayúscula / Minúscula

     Este método te puede ayudar si quieres convertir el texto de una celda de Excel en Mayúscula, Minúscula, Tipo Oración, Primera letra del texto en Mayúscula, etc.

También le quila los tildes en las vocales.


Sub MayMin()

    Dim celda As Object

    Dim opcion As Integer

    Dim texto As String

    On Error Resume Next

    

    opcion = InputBox("1.- MAYUSCULA" & Chr(13) & "2.- Minuscula" & Chr(13) & "3.- Tipo oración" & Chr(13) & "4.- 1° Letra Mayuscula")

    For Each celda In Selection

        If opcion >= 1 And opcion <= 3 Then

            If Not IsNumeric(celda.Value) And Not IsDate(celda.Value) And Not IsObject(celda.Value) And Not IsEmpty(celda.Value) And Not IsNull(celda.Value) Then _

            celda.Value = Trim(StrConv(celda.Value, opcion))

            If celda.Value Like "*Á*" Then

                celda.Value = Replace(celda.Value, "Á", "A")

            ElseIf celda.Value Like "*É*" Then

                celda.Value = Replace(celda.Value, "É", "E")

            ElseIf celda.Value Like "*Í*" Then

                celda.Value = Replace(celda.Value, "Í", "I")

            ElseIf celda.Value Like "*Ó*" Then

                celda.Value = Replace(celda.Value, "Ó", "O")

            ElseIf celda.Value Like "*Ú*" Then

                celda.Value = Replace(celda.Value, "Ú", "U")

            End If

        ElseIf opcion = 4 Then

            celda.Value = Trim(StrConv(celda.Value, 2))

            texto = StrConv(Left(celda.Value2, 1), vbUpperCase)

            celda.Value2 = texto & Mid(celda.Value2, 2, Len(celda.Value2) - 1)

        End If

    Next

End Sub

Comentarios