Excel Help Forum
ExcelTip.com
Account Icon Account Icon Account Icon
ExcelTip.com

Go Back   Excel Help Forum > Microsoft Office Application Help - Excel Help forum > Excel Programming

Reply
 
Thread Tools Display Modes
  #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: 131
JezLisle is becoming part of the community
Dates as Numbers in Combo Box



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
Valued Forum Contributor
 
Join Date: 02 Sep 2008
Location: Netherlands
Posts: 559
rwgrietveld Has established their mark in the community
re: Dates as Numbers in Combo Box

Maybe there is a better way but this works:
Code:
cboGetDate.Text = CLng(Format(cboGetDate.Value, "#######"))
__________________
... and now get outside and enjoy yourself
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: 131
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: 131
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
Valued Forum Contributor
 
Join Date: 02 Sep 2008
Location: Netherlands
Posts: 559
rwgrietveld Has established their mark in the community
Have you tried the hashes #?
__________________
... and now get outside and enjoy yourself
Ave, Ricardo
Reply With Quote
  #6  
Old 09-19-2008, 05:52 AM
royUK's Avatar
royUK royUK is offline
Forums Administrator
 
Join Date: 18 Nov 2003
Location: Lincolnshire,UK
Posts: 10,580
royUK is very confident of their ability royUK is very confident of their ability royUK is very confident of their ability
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: 131
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: 131
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

New topics in Excel Programming


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 Miscellaneous 2 05-03-2007 04:59 PM
Ordinal Numbers in Dates OfficeBitty Excel Miscellaneous 13 11-21-2006 04:34 AM


All times are GMT -4. The time now is 09:08 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0