Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Capitalise Letters

How can I write code that will capitalise the First Letter in two names that
will be typed in to a single cell? I want this to be performed automatically
without user intervention. I can use the 'Proper' function but this has to
be typed in to the cell first as part of a formula, don't want to do that

I assume it will be a Private Sub within the Worksheet triggered by an event
i.e. a value in the appropriate cell

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Capitalise Letters

Rightclick sheet tab, choose View Code, paste this in:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Shouldbe As String
With Target
If .Address = "$B$2" Then
If .HasFormula = False Then
Shouldbe = StrConv(.Value, vbProperCase)
If .Value < Shouldbe Then _
.Value = Shouldbe
End If
End If
End With
End Sub

Alter $B$2 to desired absolute cell address.

HTH. Best wishes Harald

"John" skrev i melding
...
How can I write code that will capitalise the First Letter in two names

that
will be typed in to a single cell? I want this to be performed

automatically
without user intervention. I can use the 'Proper' function but this has to
be typed in to the cell first as part of a formula, don't want to do that

I assume it will be a Private Sub within the Worksheet triggered by an

event
i.e. a value in the appropriate cell

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Capitalise Letters

Thanks Harald


"Harald Staff" wrote in message
...
Rightclick sheet tab, choose View Code, paste this in:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Shouldbe As String
With Target
If .Address = "$B$2" Then
If .HasFormula = False Then
Shouldbe = StrConv(.Value, vbProperCase)
If .Value < Shouldbe Then _
.Value = Shouldbe
End If
End If
End With
End Sub

Alter $B$2 to desired absolute cell address.

HTH. Best wishes Harald

"John" skrev i melding
...
How can I write code that will capitalise the First Letter in two names

that
will be typed in to a single cell? I want this to be performed

automatically
without user intervention. I can use the 'Proper' function but this has

to
be typed in to the cell first as part of a formula, don't want to do

that

I assume it will be a Private Sub within the Worksheet triggered by an

event
i.e. a value in the appropriate cell

Thanks






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Capitalise Letters

Hi John
This should get you started. Applies Proper to column A.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Target.Value = Application.WorksheetFunction.Proper(Target.Value)
End If
End Sub

Paste into the code module behind the sheet where you want the edit to
be performed (go to VB Editor and double click the sheet name in the
Project Window.
If you want to edit in all sheets, use the equivalent sub from the
ThisWorkBook code module.
If you want to restrict to a particular named range "MyRange" on a
sheet use Range("MyRange") instead of Range("A:A").

regards
Paul

"John" wrote in message ...
How can I write code that will capitalise the First Letter in two names that
will be typed in to a single cell? I want this to be performed automatically
without user intervention. I can use the 'Proper' function but this has to
be typed in to the cell first as part of a formula, don't want to do that

I assume it will be a Private Sub within the Worksheet triggered by an event
i.e. a value in the appropriate cell

Thanks

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
Capitalise first word in a cell alba146 Excel Discussion (Misc queries) 2 August 4th 09 11:28 AM
CAPITALISE Prasad Gopinath Excel Discussion (Misc queries) 8 March 1st 08 03:36 PM
CAPITALISE GLOBALLY Prasad Gopinath Excel Discussion (Misc queries) 5 February 10th 08 09:08 PM
how can i capitalise text in an existing workbook craigs rus Excel Worksheet Functions 1 October 31st 06 07:56 PM
Trying to Capitalise on Input to Cells John Excel Worksheet Functions 3 June 23rd 06 03:18 PM


All times are GMT +1. The time now is 05:17 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"