The current macro I am using very nicely caps all words in each cell in a column, which is the main idea. The problem is I am now running into the following issue:
Consider the following sentence in any cell in column A:
claimant's recorded statement
After the macro is ran it would obviously cap each word as follows:
Claimant's Recorded Statement
However, if the original sentence contains something with pre-existing multiple caps consecutively such as the 3 examples below where the issue pertains to MRI and QME and MI :
review of MRI Of thoracic spine
MRI Of thoracic spine
panel QME Ml-104 supplemental report
The current macro I am using would translate those 3 sentences as follows:
Review Of Mri Of Thoracic Spine
Mri Of Thoracic Spine
Panel Qme Mi-104 Supplemental Report
Instead of as it needs to be like the following:
Review Of MRI Of Thoracic Spine
MRI Of Thoracic Spine
Panel QME Ml-104 Supplemental Report
Conclusion: Because such situations only occur with such combos as MRI, QME or MI entered into the cell as caps already before the macro is even used, I was hoping there would be a way for the program to do what it currently does yet skip over any current letter already in caps and not change it OR maybe it could recognize and leave untouched or skip over any situation where a word already exists with a cap or maybe 2 caps or more already in it.
Below is the program I am using:
Sub ConvertSelectionUpper_V4()
' hiker95, 08/27/2014, ME800718
Dim c As Range, s, i As Long, s2, h As String
Application.ScreenUpdating = False
With Selection
.Value = Evaluate("=if(len(" & .Address & "),substitute(proper(" & .Address & "),"" And "","" and ""),"""")")
.Columns.AutoFit
End With
For Each c In Selection
h = ""
If InStr(c, "'") Then
s = Split(Trim(c), " ")
For i = LBound(s) To UBound(s)
If InStr(s(i), "'") Then
s2 = Split(s(i), "'")
h = h & s2(0) & "'" & LCase(s2(1)) & " "
Else
h = h + s(i) & " "
End If
Next i
If Right(h, 1) = " " Then
h = Left(h, Len(h) - 1)
End If
c = h
End If
Next c
Application.ScreenUpdating = True
End Sub
Can anyone help on this one???
Consider the following sentence in any cell in column A:
claimant's recorded statement
After the macro is ran it would obviously cap each word as follows:
Claimant's Recorded Statement
However, if the original sentence contains something with pre-existing multiple caps consecutively such as the 3 examples below where the issue pertains to MRI and QME and MI :
review of MRI Of thoracic spine
MRI Of thoracic spine
panel QME Ml-104 supplemental report
The current macro I am using would translate those 3 sentences as follows:
Review Of Mri Of Thoracic Spine
Mri Of Thoracic Spine
Panel Qme Mi-104 Supplemental Report
Instead of as it needs to be like the following:
Review Of MRI Of Thoracic Spine
MRI Of Thoracic Spine
Panel QME Ml-104 Supplemental Report
Conclusion: Because such situations only occur with such combos as MRI, QME or MI entered into the cell as caps already before the macro is even used, I was hoping there would be a way for the program to do what it currently does yet skip over any current letter already in caps and not change it OR maybe it could recognize and leave untouched or skip over any situation where a word already exists with a cap or maybe 2 caps or more already in it.
Below is the program I am using:
Sub ConvertSelectionUpper_V4()
' hiker95, 08/27/2014, ME800718
Dim c As Range, s, i As Long, s2, h As String
Application.ScreenUpdating = False
With Selection
.Value = Evaluate("=if(len(" & .Address & "),substitute(proper(" & .Address & "),"" And "","" and ""),"""")")
.Columns.AutoFit
End With
For Each c In Selection
h = ""
If InStr(c, "'") Then
s = Split(Trim(c), " ")
For i = LBound(s) To UBound(s)
If InStr(s(i), "'") Then
s2 = Split(s(i), "'")
h = h & s2(0) & "'" & LCase(s2(1)) & " "
Else
h = h + s(i) & " "
End If
Next i
If Right(h, 1) = " " Then
h = Left(h, Len(h) - 1)
End If
c = h
End If
Next c
Application.ScreenUpdating = True
End Sub
Can anyone help on this one???
Last edited: