LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default vbproper

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"