Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Proper case using VBA

How can I force 'proper' case for text within excel
The following code forces uppercase, however I would like only the first
letters of each word capitalized: ie Joe Bloggs.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("E3:F200")) Is Nothing Then
Target(1).Value = UCase(Target(1).Value)
End If
Application.EnableEvents = True
End Sub

Can this be tweaked to what I woulf like?
--
tia

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Proper case using VBA

This may work:-
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Or Target.HasFormula Then Exit Sub
Application.EnableEvents = False
Target = StrConv(Target, vbProperCase)
Application.EnableEvents = True

End Sub

Mike

"Jock" wrote:

How can I force 'proper' case for text within excel
The following code forces uppercase, however I would like only the first
letters of each word capitalized: ie Joe Bloggs.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("E3:F200")) Is Nothing Then
Target(1).Value = UCase(Target(1).Value)
End If
Application.EnableEvents = True
End Sub

Can this be tweaked to what I woulf like?
--
tia

Jock

Reply
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change from upper case to proper case in excel 2002 CT Man[_2_] Excel Discussion (Misc queries) 8 January 8th 08 06:14 PM
excel'03 how to convert a column from upper case to proper case sharie palmer Excel Discussion (Misc queries) 1 January 30th 06 11:50 PM
Excel: How do I change all upper case ss to proper case? Moosieb Excel Worksheet Functions 3 January 13th 06 12:45 AM
Changing Upper case to Proper Case Mountain Excel Worksheet Functions 1 January 13th 05 10:37 PM
Proper case Chip Pearson Excel Programming 0 August 20th 03 02:26 PM


All times are GMT +1. The time now is 07:04 PM.

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

About Us

"It's about Microsoft Excel"