ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UpperCase changes date format (https://www.excelbanter.com/excel-programming/445892-uppercase-changes-date-format.html)

MrPetreli

UpperCase changes date format
 
I have a very unusual problem with the below code, which for some reason changes the date format on all cells in my spreadsheet from dd/mm/yyyy to mm/dd/yyyy. I tried to solve it but not luck with If x.Value = IsDate(x.Value) Then Exit Sub



Sub Uppercase()

Application.ScreenUpdating = False


' Loop to cycle through each cell in the specified range.
Set URange = Selection
For Each x In URange
' Change the text in the range to uppercase letters.
x.Value = UCase(x.Value)

If x.Value = IsDate(x.Value) Then Exit Sub

Next

End Sub

GS[_2_]

UpperCase changes date format
 
MrPetreli formulated the question :
I have a very unusual problem with the below code, which for some reason
changes the date format on all cells in my spreadsheet from dd/mm/yyyy
to mm/dd/yyyy. I tried to solve it but not luck with If x.Value =
IsDate(x.Value) Then Exit Sub



Try...

Sub Uppercase()
Application.ScreenUpdating = False
Dim x As Range
For Each x In Selection
If Not IsDate(x.Value) Then x.Value = UCase(x.Value)
Next 'x
Application.ScreenUpdating = True
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com