Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel cells automatic formatting of text

I use the following data to automatically force cells that have text input
into uppercase or proper case. On the odd occasion I do not want the text
input in the listed cells to change into upper case or proper case, but to
show exactly as I have typed it in. Is there a way that I can add to the
following programming lines that will enable me to do this - e.g. can the
input be preceded with some character that prevents the text from taking on
upper case or proper case?

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range("A1,A2,A3")) Is Nothing Then
With Target
.Value = UCase(.Value)
End With
ElseIf Not Intersect(Target, Range("B1,B12")) Is Nothing Then
With Target
.Value = Application.Proper(.Value)
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Thanks in advance of any help.
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Excel cells automatic formatting of text

Something like:

With Target
if left(Target,1)="#" then
.value = right(Target,len(Target)-1)
else
.Value = UCase(.Value)
end if
End With

Should work
"John Web" wrote:

I use the following data to automatically force cells that have text input
into uppercase or proper case. On the odd occasion I do not want the text
input in the listed cells to change into upper case or proper case, but to
show exactly as I have typed it in. Is there a way that I can add to the
following programming lines that will enable me to do this - e.g. can the
input be preceded with some character that prevents the text from taking on
upper case or proper case?

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range("A1,A2,A3")) Is Nothing Then
With Target
.Value = UCase(.Value)
End With
ElseIf Not Intersect(Target, Range("B1,B12")) Is Nothing Then
With Target
.Value = Application.Proper(.Value)
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Thanks in advance of any help.
John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Excel cells automatic formatting of text

Hi,

You could preced anything you want left alone with a space and use this
code. Note I also changed target.value to target .formula. This ensure
formula won't be changed to values should you enter one in the range

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
If Left(Target.Value, 1) = " " Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("A1,A2,A3")) Is Nothing Then
With Target
.Value = UCase(.Formula)
End With
ElseIf Not Intersect(Target, Range("B1,B12")) Is Nothing Then
With Target
.Value = Application.Proper(.Formula)
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Mike

"John Web" wrote:

I use the following data to automatically force cells that have text input
into uppercase or proper case. On the odd occasion I do not want the text
input in the listed cells to change into upper case or proper case, but to
show exactly as I have typed it in. Is there a way that I can add to the
following programming lines that will enable me to do this - e.g. can the
input be preceded with some character that prevents the text from taking on
upper case or proper case?

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range("A1,A2,A3")) Is Nothing Then
With Target
.Value = UCase(.Value)
End With
ElseIf Not Intersect(Target, Range("B1,B12")) Is Nothing Then
With Target
.Value = Application.Proper(.Value)
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

Thanks in advance of any help.
John

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
Stop automatic formatting of cells (number, text, date, etc) Marcela Excel Worksheet Functions 4 June 9th 08 08:09 PM
automatic formatting of cells to currency in Excel 2007 mikky Excel Worksheet Functions 0 November 29th 06 12:16 PM
How can I get automatic row height for merged cells with text wra. ConfusedLady Excel Worksheet Functions 1 April 23rd 05 02:49 AM
mag-text in merged cells-automatic row heigh 68magnolia71 Excel Worksheet Functions 10 April 9th 05 08:43 PM
Combining & formatting cells with text - Excel 2002 Bob Excel Discussion (Misc queries) 4 March 4th 05 10:35 PM


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