Home |
Search |
Today's Posts |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Joanne,
I've had something similar to this, so I'll jump in. This should fix the state problem. It presumes that the state will always have a space before and after it. DC is included but not PR (Puerto Rico)! Notice also the change to your routine, below. James Function FixState(FixStr As String) As String Dim StateStr As String, z As Integer, Loc As Integer StateStr = " AL AK AZ AR CA CO CT DE DC FL GA HI ID IL IN IA KS KY LA " _ & " ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR " _ & " PA RI SC SD TN TX UT VT VA WA WV WI WY " For z = 1 To Len(FixStr) Loc = InStr(StateStr, UCase(Mid(FixStr, z, 4))) If Loc 0 Then FixStr = Left(FixStr, z - 1) & Mid(StateStr, Loc, 4) & Right(FixStr, Len(FixStr) - z - 3) Exit For End If Next z FixState = FixStr End Function Public Sub ProperCase() Dim Rng As Range For Each Rng In Selection.Cells If Rng.HasFormula = False Then Rng.Value = FixState(StrConv(Rng.Value, vbProperCase)) End If Next Rng End Sub |