Excel combo box

  • Thread starter Thread starter bobeverton
  • Start date Start date
B

bobeverton

Is there an easy way to maintain a date format from the original cell
through selection via a combo box?
 
If you add the items yourself--instead of using listfillrange, then the combobox
from the control toolbox toolbar will keep the formatting:

Option Explicit
Private Sub Worksheet_Activate()
Dim myCell As Range
With Me.ComboBox1
.ListFillRange = ""
.Clear
For Each myCell In Me.Range("a1:a14").Cells
.AddItem myCell.Text
Next myCell
End With
End Sub

or if you wanted to just use your own format, you could format it whenever it
changed:

Option Explicit
Dim blkProc As Boolean
Private Sub ComboBox1_Change()

If blkProc Then Exit Sub
blkProc = True
Me.ComboBox1.Value = Format(Me.ComboBox1.Value, "mm/dd/yyyy")
blkProc = False

End Sub

====
I put both of these functions behind the worksheet that held the combobox.

I don't think you'd want to use both!
 
Back
Top