Showing posts with label Converting Text Case in Excel VBA. Show all posts
Showing posts with label Converting Text Case in Excel VBA. Show all posts

Tuesday, July 5, 2011

Converting Text Case in Excel VBA :-



If You want to Convert Text Case in Selection :-

Sub ConvertProperCase()
Application.ScreenUpdating = False
    Dim Rng As Range
    For Each Rng In Selection.Cells
        If Rng.HasFormula = False Then
             'Use this line for ProperCase text; change UCase to LCase for LowerCase text.
            Rng.value = Application.Proper(Rng.value)
        End If
    Next Rng
End Sub

Sub ConvertLowerCase()
Application.ScreenUpdating = False
    Dim Rng As Range
    For Each Rng In Selection.Cells
        If Rng.HasFormula = False Then
             'Use this line for LowerCase text; change UCase to LCase for LowerCase text.
            Rng.value = LCase(Rng.value)
        End If
    Next Rng
End Sub

Sub ConvertUpperCase()
Application.ScreenUpdating = False
    Dim Rng As Range
    For Each Rng In Selection.Cells
        If Rng.HasFormula = False Then
             'Use this line for UpperCase text; change UCase to LCase for LowerCase text.
            Rng.value = UCase(Rng.value)
        End If
    Next Rng
End Sub