Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 09-18-2008, 04:19 AM
JezLisle JezLisle is offline
Forum Contributor
 
Join Date: 06 Jun 2008
Location: Manchester
MS Office Version:MS Office 2003
Posts: 143
JezLisle is becoming part of the community
Dates as Numbers in Combo Box

Please Register to Remove these Ads



I have the same problem as thread,

http://www.excelforum.com/excel-prog...ml#post1969271

When I fill the Combo Box it shows as a date in the list for selecting in the Combo Box. Once I select the Date I want it then changes back t its number format. I have tried using the code below and still no joy, where am I going wrong?

Code:
Private Sub cboGetDate_Change()
    cboGetDate.Text = Format(cboGetDate.Text, "dd/mm/yyyy")
End Sub
Reply With Quote
  #2  
Old 09-18-2008, 05:08 AM
rwgrietveld's Avatar
rwgrietveld rwgrietveld is offline
Forum Guru
 
Join Date: 02 Sep 2008
Location: Netherlands
MS Office Version:XL 2007 / XL 2010
Posts: 1,643
rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability
re: Dates as Numbers in Combo Box

Maybe there is a better way but this works:
Code:
cboGetDate.Text = CLng(Format(cboGetDate.Value, "#######"))
__________________
Looking for great solutions but hate waiting?
Seach this Forum through Google

www.Google.com
(e.g. +multiple +IF site:excelforum.com/excel-general/ )

www.Google.com
(e.g. +fill +combobox site:excelforum.com/excel-programming/ )

Ave,
Ricardo
Reply With Quote
  #3  
Old 09-18-2008, 08:59 AM
JezLisle JezLisle is offline
Forum Contributor
 
Join Date: 06 Jun 2008
Location: Manchester
MS Office Version:MS Office 2003
Posts: 143
JezLisle is becoming part of the community
I have tried this and keep getting a Type Mismatch error on the section

Code:
cboGetDate.Text = CLng(Format(cboGetDate.Value, "dd/mm/yyyy"))
When I hover over it on the Debug it shows me the date as a number still


Code:
Private Sub cboGetDate_Change()
    'cboGetDate.Text = Format(cboGetDate.Text, "dd/mm/yyyy")
    cboGetDate.Text = CLng(Format(cboGetDate.Value, "dd/mm/yyyy"))
End Sub
Where am I going wrong?
Reply With Quote
  #4  
Old 09-19-2008, 04:45 AM
JezLisle JezLisle is offline
Forum Contributor
 
Join Date: 06 Jun 2008
Location: Manchester
MS Office Version:MS Office 2003
Posts: 143
JezLisle is becoming part of the community
I have tried this code and still when selecting the dates in the Combo Box they appear as a number format

Code:
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
I cant see where am going wrong?
Reply With Quote
  #5  
Old 09-19-2008, 05:44 AM
rwgrietveld's Avatar
rwgrietveld rwgrietveld is offline
Forum Guru
 
Join Date: 02 Sep 2008
Location: Netherlands
MS Office Version:XL 2007 / XL 2010
Posts: 1,643
rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability rwgrietveld is very confident of their ability
Have you tried the hashes #?
__________________
Looking for great solutions but hate waiting?
Seach this Forum through Google

www.Google.com
(e.g. +multiple +IF site:excelforum.com/excel-general/ )

www.Google.com
(e.g. +fill +combobox site:excelforum.com/excel-programming/ )

Ave,
Ricardo
Reply With Quote
  #6  
Old 09-19-2008, 05:52 AM
royUK's Avatar
royUK royUK is online now
Forums Administrator
 
Join Date: 18 Nov 2003
Location: Derbyshire,UK
MS Office Version:Xp; 2007
Posts: 13,767
royUK Has a higher level of understanding royUK Has a higher level of understanding royUK Has a higher level of understanding royUK Has a higher level of understanding royUK Has a higher level of understanding royUK Has a higher level of understanding royUK Has a higher level of understanding
Have you tried DateSerial?
Can you attach the workbook?
__________________
Hope that helps.

RoyUK
--------
If you are pleased with a member's answer then use the Scales icon to rate it

For Excel consulting, free examples and tutorials visit my site
Check out the free Excel Toolbar

New members please read & follow the Forum Rules

Remember to mark your questions Solved and rate the answer(s)


Code Tags: Make your code easier for us to read
Reply With Quote
  #7  
Old 09-19-2008, 06:01 AM
JezLisle JezLisle is offline
Forum Contributor
 
Join Date: 06 Jun 2008
Location: Manchester
MS Office Version:MS Office 2003
Posts: 143
JezLisle is becoming part of the community
I've tried the Hash's

Attached is the file I'm using to test things out...

Its also the same file that the other thread I have open is (Running Stored Procedures from Excel)

Thanks
Attached Files
File Type: xls SQLServerConnection.xls (58.5 KB, 1 views)
Reply With Quote
  #8  
Old 09-19-2008, 06:20 AM
JezLisle JezLisle is offline
Forum Contributor
 
Join Date: 06 Jun 2008
Location: Manchester
MS Office Version:MS Office 2003
Posts: 143
JezLisle is becoming part of the community
I have tried this code below and it seems to work like it should...

Code:
Private Sub cboGetDate_Change()
    MyDate = Format(cboGetDate.Value, "dd/mm/yyyy")
    cboGetDate.Value = Format(MyDate, "dd/mm/yyyy")
End Sub
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel keeps converting numbers to dates on copy/paste zazu88hike Excel General 3 01-27-2009 01:36 PM
dates converting to serial numbers henro8 Excel Programming 1 06-24-2008 03:38 PM
I need to format various strings (numbers, dates) precisely durandal05 Excel Programming 5 06-10-2008 08:55 PM
Adding numbers to output dates MasterMonk Excel General 2 05-03-2007 04:59 PM
Ordinal Numbers in Dates OfficeBitty Excel General 13 11-21-2006 04:34 AM