Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Voodoodan
 
Posts: n/a
Default 3 letter capitalisation


Hiya,

I've modified a bit of code, below, so that if someone types anything
into cell C25, then it capitalises the first letter.

Is there any way of modifying it a little bit more so that, as well as
the above, if someone types in a 3-letter word then it capitalises all
three letters?

So, if I enter 'daniel', it returns 'Daniel'. If I enter 'dan' it
returns 'DAN'.


Private Sub Worksheet_Change(ByVal Target As Excel.Range)

On Error GoTo ErrHandler
If Target.Count = 1 And Target.Column = 3 Then
Application.EnableEvents = False
sStr = Target.Value
Target.Value = UCase(Left(sStr, 1)) & LCase( _
Mid(sStr, 2))
End If
ErrHandler:
Application.EnableEvents = True
End Sub


Many thanks,
Dan.


--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default 3 letter capitalisation

How about:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myConversion As Long
Dim sStr As String

On Error GoTo ErrHandler

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("c:c")) Is Nothing Then Exit Sub

Select Case Len(Target.Value)
Case Is = 3: myConversion = vbUpperCase
Case Else: myConversion = vbProperCase
End Select

sStr = StrConv(Target.Value, myConversion)

If sStr < Target.Value Then
Application.EnableEvents = False
Target.Value = sStr
End If

ErrHandler:
Application.EnableEvents = True
End Sub


Voodoodan wrote:

Hiya,

I've modified a bit of code, below, so that if someone types anything
into cell C25, then it capitalises the first letter.

Is there any way of modifying it a little bit more so that, as well as
the above, if someone types in a 3-letter word then it capitalises all
three letters?

So, if I enter 'daniel', it returns 'Daniel'. If I enter 'dan' it
returns 'DAN'.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

On Error GoTo ErrHandler
If Target.Count = 1 And Target.Column = 3 Then
Application.EnableEvents = False
sStr = Target.Value
Target.Value = UCase(Left(sStr, 1)) & LCase( _
Mid(sStr, 2))
End If
ErrHandler:
Application.EnableEvents = True
End Sub

Many thanks,
Dan.

--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick
 
Posts: n/a
Default 3 letter capitalisation

Dan,

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim sStr As String

On Error GoTo ErrHandler
If Target.Count = 1 And Target.Column = 3 Then
Application.EnableEvents = False
sStr = Target.Value
If Len(sStr) = 3 Then
Target.Value = UCase(sStr)
Else
Target.Value = UCase(Left(sStr, 1)) & LCase( _
Mid(sStr, 2))
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub

--
HTH,
Bernie
MS Excel MVP


"Voodoodan" wrote in message
...

Hiya,

I've modified a bit of code, below, so that if someone types anything
into cell C25, then it capitalises the first letter.

Is there any way of modifying it a little bit more so that, as well as
the above, if someone types in a 3-letter word then it capitalises all
three letters?

So, if I enter 'daniel', it returns 'Daniel'. If I enter 'dan' it
returns 'DAN'.


Private Sub Worksheet_Change(ByVal Target As Excel.Range)

On Error GoTo ErrHandler
If Target.Count = 1 And Target.Column = 3 Then
Application.EnableEvents = False
sStr = Target.Value
Target.Value = UCase(Left(sStr, 1)) & LCase( _
Mid(sStr, 2))
End If
ErrHandler:
Application.EnableEvents = True
End Sub


Many thanks,
Dan.


--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301



  #4   Report Post  
Posted to microsoft.public.excel.misc
Voodoodan
 
Posts: n/a
Default 3 letter capitalisation


Thanks very much for your contributions.

I have used Dave's version, which got to me through email first, and it
works perfectly!

Thanks again,
Dan.


--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301

  #5   Report Post  
Posted to microsoft.public.excel.misc
Bernard Liengme
 
Posts: n/a
Default 3 letter capitalisation

But what happens if I type May or Amy? Do these have to be capitalized even
when they are not contractions?
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Voodoodan" wrote
in message ...

Thanks very much for your contributions.

I have used Dave's version, which got to me through email first, and it
works perfectly!

Thanks again,
Dan.


--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile:
http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301





  #6   Report Post  
Posted to microsoft.public.excel.misc
Voodoodan
 
Posts: n/a
Default 3 letter capitalisation


The data being entered is specialised, so there'll be no need to type in
any general, everyday names, as such.

I've actually modified it a little now to capitalise all letters within
2-5 letters. This is because when people enter these words they will be
acronyms of a certain team/unit. However, anything over 5 letters will
likely be a team/unit's name in full, so it just needs the first letter
to be capitalised.

Dan.


--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301

  #7   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default 3 letter capitalisation

Just curious, did you change the code so it looked like:

Select Case Len(Target.Value)
Case 2 To 5: myConversion = vbUpperCase
Case Else: myConversion = vbProperCase
End Select

(just checking on you <bg)

Voodoodan wrote:

The data being entered is specialised, so there'll be no need to type in
any general, everyday names, as such.

I've actually modified it a little now to capitalise all letters within
2-5 letters. This is because when people enter these words they will be
acronyms of a certain team/unit. However, anything over 5 letters will
likely be a team/unit's name in full, so it just needs the first letter
to be capitalised.

Dan.

--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
Voodoodan
 
Posts: n/a
Default 3 letter capitalisation


Close, I did it this way, however I prefer the neatness of your line!

Select Case Len(Target.Value)
Case Is = 2, 3, 4, 5: myConversion = vbUpperCase
Case Else: myConversion = vbProperCase
End Select

Dan.




Dave Peterson Wrote:
Just curious, did you change the code so it looked like:

Select Case Len(Target.Value)
Case 2 To 5: myConversion = vbUpperCase
Case Else: myConversion = vbProperCase
End Select

(just checking on you <bg)

Voodoodan wrote:

The data being entered is specialised, so there'll be no need to type

in
any general, everyday names, as such.

I've actually modified it a little now to capitalise all letters

within
2-5 letters. This is because when people enter these words they will

be
acronyms of a certain team/unit. However, anything over 5 letters

will
likely be a team/unit's name in full, so it just needs the first

letter
to be capitalised.

Dan.

--
Voodoodan

------------------------------------------------------------------------
Voodoodan's Profile:

http://www.excelforum.com/member.php...nfo&userid=597
View this thread:

http://www.excelforum.com/showthread...hreadid=505301

--

Dave Peterson



--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301

  #9   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default 3 letter capitalisation

Putting all the numbers is a nice way if you wanted to skip one of them. But
way too much work if you were checking up to (say) 32000 characters <vvbg.



Voodoodan wrote:

Close, I did it this way, however I prefer the neatness of your line!

Select Case Len(Target.Value)
Case Is = 2, 3, 4, 5: myConversion = vbUpperCase
Case Else: myConversion = vbProperCase
End Select

Dan.

Dave Peterson Wrote:
Just curious, did you change the code so it looked like:

Select Case Len(Target.Value)
Case 2 To 5: myConversion = vbUpperCase
Case Else: myConversion = vbProperCase
End Select

(just checking on you <bg)

Voodoodan wrote:

The data being entered is specialised, so there'll be no need to type

in
any general, everyday names, as such.

I've actually modified it a little now to capitalise all letters

within
2-5 letters. This is because when people enter these words they will

be
acronyms of a certain team/unit. However, anything over 5 letters

will
likely be a team/unit's name in full, so it just needs the first

letter
to be capitalised.

Dan.

--
Voodoodan

------------------------------------------------------------------------
Voodoodan's Profile:

http://www.excelforum.com/member.php...nfo&userid=597
View this thread:

http://www.excelforum.com/showthread...hreadid=505301

--

Dave Peterson


--
Voodoodan
------------------------------------------------------------------------
Voodoodan's Profile: http://www.excelforum.com/member.php...nfo&userid=597
View this thread: http://www.excelforum.com/showthread...hreadid=505301


--

Dave Peterson
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
Merge address in XL to Word letter template TheOne Excel Discussion (Misc queries) 1 December 7th 05 10:25 PM
Pulling a Letter from a cell and filling another cell with info nick s Excel Worksheet Functions 16 November 28th 05 04:10 AM
Convert Text (letter) To Number Excel reloadinternet Excel Worksheet Functions 2 August 22nd 05 03:49 PM
numerical value of a letter Graeme Excel Worksheet Functions 1 July 20th 05 10:21 AM
Have A Letter Reference A Name For An Intoduction travelersway New Users to Excel 2 February 16th 05 05:47 PM


All times are GMT +1. The time now is 07:53 AM.

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"