Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problems with date format in userforms
I'm having trouble with dates entered via a userform. When
I enter a date in the format dd/mm/yyyy everything is ok. I then go and work out the work days between the 2 dates entered. When I next enter the form it shows my date in the format mm/dd/yyyy and if I don't notice and re-enter the date I work out the wrong work days. What do I need to do to get around this problem? Data entered from a userform doesn't seem to take any notice of cell format definitions. The cell is defined as date of type 14/03/2001. The user enters a start and end date then clicks a button which has the associated code: If Not IsDate(Me.TB_A1_SDt.Text) Then MsgBox ("Must be a valid Date!") Me.TB_A1_SDt.Text = "" Me.TB_A1_SDt.SetFocus Else If Not IsDate(Me.TB_A1_ED.Text) Then MsgBox ("Must be a valid Date!") Me.TB_A1_ED.Text = "" Me.TB_A1_ED.SetFocus Else Sheets("AutumnHT1").Cells(2, 1).Formula = CVDate (UserForm1.TB_A1_SDt.Text) Sheets("AutumnHT1").Cells(1, 4).Formula = CVDate (UserForm1.TB_A1_ED.Text) Unload UserForm1 Load UserForm2 UserForm2.Show Exit Sub End If End If End Sub I needed to use the CVDATE function to ensure that it was copied from the userform to the cell as a valid date otherwise it was text. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date format problems | Charts and Charting in Excel | |||
Date format problems ... | Excel Discussion (Misc queries) | |||
Date Format Problems?? | Excel Discussion (Misc queries) | |||
UserForms compatibility problems | Excel Programming | |||
Problems designing userforms | Excel Programming |