With code from Rick Rothstein (MVP - VB), I have this modified code.
I have no idea how he figured this out, but damn, thats some skill.
Sub ConvertCase()
Dim rAcells As Range
Dim rLoopCells As Range
Dim X As Long
Dim lReply As Long
Dim TextLine As String
Dim Parsed() As String
'Set variable to needed cells
If Selection.Cells.Count = 1 Then
Set rAcells = ActiveSheet.UsedRange
Else
Set rAcells = Selection
End If
On Error Resume Next 'In case of NO text constants.
'Set variable to all text constants
Set rAcells = rAcells.SpecialCells(xlCellTypeConstants, xlTextValues)
If rAcells Is Nothing Then
MsgBox "Could not find any text."
On Error GoTo 0
Exit Sub
End If
lReply = MsgBox("Select 'Yes' for UPPER CASE; 'No' for Proper Case.", _
vbYesNoCancel, "OzGrid.com")
If lReply = vbCancel Then Exit Sub
For Each rLoopCells In rAcells
TextLine = Replace(rLoopCells, ")", "()")
Parsed = Split(TextLine, "(")
For X = 0 To UBound(Parsed) Step 2
Parsed(X) = StrConv(Parsed(X), IIf(lReply = vbYes, _
vbUpperCase, vbProperCase))
Next
rLoopCells = Replace(Join(Parsed, "("), "()", ")")
Next
End Sub
Bookmarks