Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 50
Default Auto capital letter in a cell

C5:F5 is merge cell of sheet 1, I want whenever wright somthing on the merge
cell it will be automatically capital letter without using caps lock button,
For this reason I wrote for help & got a VBA code from this forum. Then I
copy, past & change the range in my VBA Editor follows -
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = C5:F5
Application.EnableEvents = False
If Application.WorksheetFunction.IsText(r) Then
r.Value = UCase(r.Value)
End If
Application.EnableEvents = True
End Sub
but its not working, What should I do. Help me
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Auto capital letter in a cell

Change this line:

Set r = C5:F5

Change to:

Set r = Range("C5")

--
Biff
Microsoft Excel MVP


"Montu" wrote in message
...
C5:F5 is merge cell of sheet 1, I want whenever wright somthing on the
merge
cell it will be automatically capital letter without using caps lock
button,
For this reason I wrote for help & got a VBA code from this forum. Then I
copy, past & change the range in my VBA Editor follows -
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = C5:F5
Application.EnableEvents = False
If Application.WorksheetFunction.IsText(r) Then
r.Value = UCase(r.Value)
End If
Application.EnableEvents = True
End Sub
but its not working, What should I do. Help me



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Auto capital letter in a cell

You have to iterate through the cells in the range r

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Me.Range("C5:F5")
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In r
cell.Value = UCase(cell.Value)
Next cell
stoppit:
Application.EnableEvents = True
End Sub

Or do it this way without iteration..........

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C5:F5" '<=== change to suit
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Value = UCase(.Value)
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Note: allways best to trap for errors and turn events back on if an error is
encountered.


Gord Dibben MS Excel MVP

On Fri, 21 Dec 2007 22:05:01 -0800, Montu wrote:

C5:F5 is merge cell of sheet 1, I want whenever wright somthing on the merge
cell it will be automatically capital letter without using caps lock button,
For this reason I wrote for help & got a VBA code from this forum. Then I
copy, past & change the range in my VBA Editor follows -
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = C5:F5
Application.EnableEvents = False
If Application.WorksheetFunction.IsText(r) Then
r.Value = UCase(r.Value)
End If
Application.EnableEvents = True
End Sub
but its not working, What should I do. Help me


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Auto capital letter in a cell

Jeez

Missed the part about merged cells......my brain won't even let the words
"merged cells" register<g

See Biff's reply.


Gord

On Sat, 22 Dec 2007 15:18:55 -0800, Gord Dibben <gorddibbATshawDOTca wrote:

You have to iterate through the cells in the range r

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Me.Range("C5:F5")
On Error GoTo stoppit
Application.EnableEvents = False
For Each cell In r
cell.Value = UCase(cell.Value)
Next cell
stoppit:
Application.EnableEvents = True
End Sub

Or do it this way without iteration..........

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C5:F5" '<=== change to suit
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Value = UCase(.Value)
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Note: allways best to trap for errors and turn events back on if an error is
encountered.


Gord Dibben MS Excel MVP

On Fri, 21 Dec 2007 22:05:01 -0800, Montu wrote:

C5:F5 is merge cell of sheet 1, I want whenever wright somthing on the merge
cell it will be automatically capital letter without using caps lock button,
For this reason I wrote for help & got a VBA code from this forum. Then I
copy, past & change the range in my VBA Editor follows -
Private Sub Worksheet_Change(ByVal Target As Range)
Set r = C5:F5
Application.EnableEvents = False
If Application.WorksheetFunction.IsText(r) Then
r.Value = UCase(r.Value)
End If
Application.EnableEvents = True
End Sub
but its not working, What should I do. Help me


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
automatic capital letter in a cell capital letter Excel Worksheet Functions 1 November 6th 07 10:19 AM
How to recognise a small letter as being different to a capital le Suza Excel Discussion (Misc queries) 4 December 28th 06 02:37 PM
New Validation option to format 1st letter as Capital letter Jeff Excel Discussion (Misc queries) 5 July 13th 06 05:11 AM
Default Capital letter for 1st letter of a word Jeff Excel Discussion (Misc queries) 6 July 10th 06 08:36 AM
Turn to capital letter SBárbara Excel Discussion (Misc queries) 2 June 22nd 06 05:18 PM


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

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"