View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ray Kanner[_2_] Ray Kanner[_2_] is offline
external usenet poster
 
Posts: 14
Default Formatting a ComboBox selection

Tom, Thanks. I actually meant the combobox itself (not
NewStart), but I did have the combobox linked to NewStart
which I broke. Unfortunately, now, nothing displays. It
seems like the ComboBox1.Clear clears it. If I comment it
out, everything works and formats correcetly, except that
the items don't reset themselves when I change the value
of the ranges Start or End, which is what I really need. I
must be missing something basic here. Thanks

Ray
-----Original Message-----
Do you mean in Range("NewStart")?

Private Sub ComboBox1_Change()
Range("NewStart").Value = ComboBox1.Value
Range("NewStart").NumberFormat = "mmm-yy"
End Sub

since you are loading the combobox dropdown with strings,

you shouldn't have
any problem with what is displayed in the combobox

itself. You don't have
the combobox linked to NewStart do you? If so, break the

link.

--
Regards,
Tom Ogilvy


Ray Kanner wrote in message
...
The code below creates a ComboBox consisting of all of

the
first (day) in month dates in between a start date and

an
end date. I am having problems with the formatting of

the
ComboBox control. When I click on the drop down, I see

all
of the dates in the correct date format (e.g. Jan-00,

Feb-
00, etc). However, when I select one of the dates, it
appears as a serial value and not formatted. How do I

get
it formatted? Thanks in advance - any help is

appreciated.

Ray Kanner

Private Sub ComboBox1_DropButtonClick()
Dim s As Date, e As Date, i As Date

s = Range("Start").Value
e = Range("End").Value

ComboBox1.Clear
i = DateSerial(Year(s), Month(s), 1)

Do While i < e
ComboBox1.AddItem Format(i, "mmm-yy")
i = DateAdd("m", 1, i)
Loop

End Sub

Private Sub ComboBox1_Change()
Range("NewStart").Value = ComboBox1.Value
End Sub



.