Quantcast
Viewing all articles
Browse latest Browse all 11829

Excel date format is wrong after setting whole worksheet to capitals

Hi,

One of our users asked me to have all text in a sheet in capitals so I fixed this by adding this code to the sheet :

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell   As Range
    On Error Resume Next
    Application.EnableEvents = False
    For Each cell In Target
        cell = UCase(cell)
    Next
    Application.EnableEvents = True
End Sub

This works fine, whenever she enter text, it's automatically converted to caps.

However, since I added the code, the date format has changed from Dutch (dd/mm/yyyy) to English (mm/dd/yyyy).
When she enters a date of which the first two characters are smaller than 13, it gets converted to mm/dd, and when she enters a date greater than 12, it gets correctly formatted as dd/mm.

The cell format is set to a standard date type, with the correct locale but the code somehow overwrites the format.
When I remove the code, the format is correct again.

For now I've fixed this by simply applying a custom format but I would like to know if this is normal behavior and if there's
another way to solve this?

Regards,

Dennis


Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>