Advice for correct date to be shown on worksheet & in userform

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
On my worksheet i type in a cell 01/04/2023 BUT when i leave the cell i see it change to 04/01/2023

I open my userform & for the date issue above i see the dat as 1/4/2023 in the Listbox
Onb the worksheet the date is in column E4 then down the page

Right clicking the worksheet cell & selecting format its shown as in screenshot

Please see screenshot for the date issue that i mention.

My goal is to code so when i type 01/04/2023 the worksheet DOES NOT change ^ also the uderform also shows 01/04/2023

Many Thanks
 

Attachments

  • EaseUS_2023_09_28_10_44_22.jpg
    EaseUS_2023_09_28_10_44_22.jpg
    27.7 KB · Views: 7
  • EaseUS_2023_09_28_10_45_25.jpg
    EaseUS_2023_09_28_10_45_25.jpg
    93.1 KB · Views: 6
So i click on 04/01/2023 then do the immediate window & i see 44930
That's January 4th alright so there is no point in working with the formatting until Excel accepts the date you actually want.
Go back to that 04/01/2023 cell and delete it, set the cell formatting to General and try typing in 01/04/2023 again.
Your regional setting should accept at first of April 2023 and that .value2 = 45017
If it isn't then you got something else going on that needs fixed
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
See below
I deleted it & typed 01/04/2023 & no changed happened.
I put the code back & typed 01/04/2023 & watched it change to 04/01/2023


Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Count = 1 And Not .HasFormula Then
            Application.EnableEvents = False
            .Value = UCase(.Value)
            Application.EnableEvents = True
        End If
    End With
    
End Sub
 
Upvote 0
Ive deleted that code so will leave it like so as it work.

Thanks
 
Upvote 0
I think that's a good idea... don't know why you would upper case a column of dates like that anyway.
 
Upvote 0

Forum statistics

Threads
1,215,103
Messages
6,123,112
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top