Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Upper case and Date problem

Hello,

I am using the following code to try to make all text in my worksheet go
to Upper case:

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

However, when I enter dates into my worksheet whilst using the
above-mentioned code, the format of the dates changes from dd-mmm-yy
(eg:14-Mar-01) to dd/mm/yyyy (eg: 14/03/2001). I tried to format the
date cells but was unable to change the date format back to dd-mmm-yy.

If I disable the above-mentioned code, I am able to change the date
format back to dd-mmm-yy.

Could someone please advise on how I can change my worksheet's text to
upper case whilst preserving the date format in dd-mmm-yy?

Any help would be greatly appreciated.

Kind regards,

Chris.

Live Long and Prosper :-)

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Upper case and Date problem

Hi Chris,

Try this...

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A3:AZ102")) Is Nothing Then
If Not IsDate(Target.Value) Then
Target.Value = UCase(Target.Value)
Else
Target.Value = Format(Target.Value, "dd-mmm-yy")
End If
End If
Application.EnableEvents = True
End Sub

--
Anant


"Chris Hankin" wrote:

Hello,

I am using the following code to try to make all text in my worksheet go
to Upper case:

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

However, when I enter dates into my worksheet whilst using the
above-mentioned code, the format of the dates changes from dd-mmm-yy
(eg:14-Mar-01) to dd/mm/yyyy (eg: 14/03/2001). I tried to format the
date cells but was unable to change the date format back to dd-mmm-yy.

If I disable the above-mentioned code, I am able to change the date
format back to dd-mmm-yy.

Could someone please advise on how I can change my worksheet's text to
upper case whilst preserving the date format in dd-mmm-yy?

Any help would be greatly appreciated.

Kind regards,

Chris.

Live Long and Prosper :-)

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Upper case and Date problem

Hello Anant Basant,

Thanks for all your help - very much appreciated.

Cheers,

Chris.

Live Long and Prosper :-)

*** Sent via Developersdex http://www.developersdex.com ***
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
Changing file in all upper case to upper and lower case Sagit Excel Discussion (Misc queries) 15 May 30th 07 06:08 AM
upper\lower case formula problem shakey1181 Excel Discussion (Misc queries) 0 November 21st 06 10:14 AM
Upper Case and date format issue Andy Tallent Excel Discussion (Misc queries) 3 April 8th 05 04:52 AM
Upper & Lower case problem in VBA Rob Excel Discussion (Misc queries) 2 February 10th 05 07:46 AM
Upper/Lower case problem Wild Bill[_2_] Excel Programming 5 August 21st 03 12:46 AM


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