#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 122
Default Combo Box Formatting

I set up a combo box using the control toolbox. The list is a list of dates,
however once a date is selected it comes back as the number format instead of
the date format. I have formatted the linked cells and the linked list to
show as date but that still hasnt worked.

How do I get this field formatted to show the date not the number?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Combo Box Formatting

Combo boxes and dates do not get along. The reason is that like text boxes
and such they deal with text and not numbers or dates. The best option is to
use helper columns or such to coerce the dates to text prior to loading them
to the combo box. You then need to use a helper cell to coerce the text back
to a date from the linked cell. Kind of a pain... have you considered using a
date picker control. It is better designed to handle dates...

On the control toolbox hit the icon that looks like a hammer and wrench with
3 dots. Select the Microsoft Date and Time Picker control. It looks like a
standard combo box but it pops up a calendar when you activate the drop
down...
--
HTH...

Jim Thomlinson


"Melissa" wrote:

I set up a combo box using the control toolbox. The list is a list of dates,
however once a date is selected it comes back as the number format instead of
the date format. I have formatted the linked cells and the linked list to
show as date but that still hasnt worked.

How do I get this field formatted to show the date not the number?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 122
Default Combo Box Formatting

That worked...yay.....Now how can I write the code that once a date is chosen
an assigned macro will run?

The by key codes that I normally use for the combo box are not working the
same.





"Jim Thomlinson" wrote:

Combo boxes and dates do not get along. The reason is that like text boxes
and such they deal with text and not numbers or dates. The best option is to
use helper columns or such to coerce the dates to text prior to loading them
to the combo box. You then need to use a helper cell to coerce the text back
to a date from the linked cell. Kind of a pain... have you considered using a
date picker control. It is better designed to handle dates...

On the control toolbox hit the icon that looks like a hammer and wrench with
3 dots. Select the Microsoft Date and Time Picker control. It looks like a
standard combo box but it pops up a calendar when you activate the drop
down...
--
HTH...

Jim Thomlinson


"Melissa" wrote:

I set up a combo box using the control toolbox. The list is a list of dates,
however once a date is selected it comes back as the number format instead of
the date format. I have formatted the linked cells and the linked list to
show as date but that still hasnt worked.

How do I get this field formatted to show the date not the number?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Combo Box Formatting

Put the worksheet in design mode by selecting the Ruler and Triangle icon on
the control toolbox. Double click the combo box or date picker and you will
be taken to the VBE where a code stub will be written for you ... Add your
code...
--
HTH...

Jim Thomlinson


"Melissa" wrote:

That worked...yay.....Now how can I write the code that once a date is chosen
an assigned macro will run?

The by key codes that I normally use for the combo box are not working the
same.





"Jim Thomlinson" wrote:

Combo boxes and dates do not get along. The reason is that like text boxes
and such they deal with text and not numbers or dates. The best option is to
use helper columns or such to coerce the dates to text prior to loading them
to the combo box. You then need to use a helper cell to coerce the text back
to a date from the linked cell. Kind of a pain... have you considered using a
date picker control. It is better designed to handle dates...

On the control toolbox hit the icon that looks like a hammer and wrench with
3 dots. Select the Microsoft Date and Time Picker control. It looks like a
standard combo box but it pops up a calendar when you activate the drop
down...
--
HTH...

Jim Thomlinson


"Melissa" wrote:

I set up a combo box using the control toolbox. The list is a list of dates,
however once a date is selected it comes back as the number format instead of
the date format. I have formatted the linked cells and the linked list to
show as date but that still hasnt worked.

How do I get this field formatted to show the date not the number?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Combo Box Formatting

You could also add the items to the combobox using .additem--and format the
dates anyway you want.

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range

With Worksheets("Sheet1")
Set myRng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
.ComboBox1.Clear
.ComboBox1.ListFillRange = "" 'just in case!
For Each myCell In myRng.Cells
'.ComboBox1.AddItem myCell.Text
.ComboBox1.AddItem Format(myCell.Value, "mmmm dd, yyyy")
Next myCell
End With
End Sub

You could use the .text property if the value in the cell was nicely
displayed--or format the date in an unambigous manner.

I'm not sure when you'd want to populate that combobox--when the workbook opens
(use auto_open or workbook_open) or when the worksheet is selected
(worksheet_activate event)????

Melissa wrote:

I set up a combo box using the control toolbox. The list is a list of dates,
however once a date is selected it comes back as the number format instead of
the date format. I have formatted the linked cells and the linked list to
show as date but that still hasnt worked.

How do I get this field formatted to show the date not the number?


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
combo reference on another combo box for picking address etc. kbjin Excel Worksheet Functions 1 December 8th 06 03:29 PM
combo box formatting ynissel Excel Discussion (Misc queries) 0 July 25th 05 05:49 PM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 1 February 16th 05 02:05 AM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 0 February 15th 05 07:45 PM
combo box formatting scrabtree23 Excel Discussion (Misc queries) 1 December 4th 04 05:07 PM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"