Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get a Date to show as a Date Format in Combo Box
I have a combo Box which can select a date but it just displays as the Number
format, I have this code below to change the format but doesnt seem to do anything when I select a Date it still shows as a number format. Where have I gone wrong? Private Sub cboGetDate_Change() Dim GetDate As Date If GetDate = CDate(cboGetDate.Value) Then cboGetDate.Value = Format(CDate(cboGetDate.Value), "dd/mm/yyyy") Else End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get a Date to show as a Date Format in Combo Box
Your declaring then testing against GetDate. This will fail as the value
will be 00:00:00 -- Regards, Nigel "Jez" wrote in message ... I have a combo Box which can select a date but it just displays as the Number format, I have this code below to change the format but doesnt seem to do anything when I select a Date it still shows as a number format. Where have I gone wrong? Private Sub cboGetDate_Change() Dim GetDate As Date If GetDate = CDate(cboGetDate.Value) Then cboGetDate.Value = Format(CDate(cboGetDate.Value), "dd/mm/yyyy") Else End If End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get a Date to show as a Date Format in Combo Box
How do I get around this?
"Nigel" wrote: Your declaring then testing against GetDate. This will fail as the value will be 00:00:00 -- Regards, Nigel "Jez" wrote in message ... I have a combo Box which can select a date but it just displays as the Number format, I have this code below to change the format but doesnt seem to do anything when I select a Date it still shows as a number format. Where have I gone wrong? Private Sub cboGetDate_Change() Dim GetDate As Date If GetDate = CDate(cboGetDate.Value) Then cboGetDate.Value = Format(CDate(cboGetDate.Value), "dd/mm/yyyy") Else End If End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get a Date to show as a Date Format in Combo Box
What do you think this line is testing against?
If GetDate = CDate(cboGetDate.Value) Then You haven't assigned anything to the GetDate variable so it doesn't have a date in it that your ComboBox can be equated to. I'm also not too sure what your code is supposed to be doing. I presume cboGetDate is the ComboBox.. you are trying to test if the item selected by the user is equal to GetDate (which, as pointed out above, has nothing in it) and, if it did equal GetDate, you are trying to format the entry the user selected and put it back into the ComboBox??? Why aren't you just loading up the ComboBox with the correct text to begin with? Perhaps you need to provide more detail about your set up, why it is the way it is and what you are trying to change about it? Right now, I am confused about what you are trying to do. -- Rick (MVP - Excel) "Jez" wrote in message ... I have a combo Box which can select a date but it just displays as the Number format, I have this code below to change the format but doesnt seem to do anything when I select a Date it still shows as a number format. Where have I gone wrong? Private Sub cboGetDate_Change() Dim GetDate As Date If GetDate = CDate(cboGetDate.Value) Then cboGetDate.Value = Format(CDate(cboGetDate.Value), "dd/mm/yyyy") Else End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I want my combo box to return a date format instead of a number? | Excel Discussion (Misc queries) | |||
keep date format in a Combo box | Excel Worksheet Functions | |||
UK date format and combo box | Excel Programming | |||
Date-Format of Dropdown-Combo is integer | Excel Programming | |||
Date format when using combo box | Excel Programming |