Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Formatting a ComboBox selection

Tom, Thanks a lot - that did it.

Ray
-----Original Message-----
Actually, I didn't notice it was doing that. But this

fixed it:

Private Sub ComboBox1_Click()
Dim sStr As String
Dim lVal As Long
' I needed this next line for xl97.
ActiveCell.Activate
If bBlockEvents Then Exit Sub
sStr = ComboBox1.Value
sStr = Left(sStr, 3) & " 1, "
lVal = Right(ComboBox1.Value, 2)
If lVal 90 Then
lVal = lVal + 1900
Else
lVal = lVal + 2000
End If
sStr = sStr & Format(lVal, "0000")
Range("NewStart").Value = sStr
Range("NewStart").NumberFormat = "mmm-yy"
End Sub

--
Regards,
Tom Ogilvy


Ray Kanner wrote in message
...
Tom, I did get it to work (kind of), but for the life of
me, I am not sure I understand what is going on. What I
mean by kind of, is I don't really think it works with

the
format I have used. If I use a "mm/dd/yy" format, it

works
fine. However, when I use the "mmm-yy" format shown,

then
when Range("NewStart").Value = ComboBox1.Value is
executed, it does not do the date conversion correctly.

It
just takes the "mmm-yy" and converts it to "mm/yy/04"

(04
because that's the current year). Is that what you get

too?

Thanks again.

Ray
-----Original Message-----
Yes, Ray, it worked fine for me.

--
Regards,
Tom Ogilvy

Ray Kanner wrote in message
...
Tom, Thanks. Did this work for you? I can't get it to
display anything for me. I just get a drop down box

of 1
item and it's blank. I also tried to remove the

Change
procs and relinking the cell NewStart but that does

the
same thing, i.e. one line item to select and nothing

in
it. Thanks.

Ray
-----Original Message-----
Actually, that didn't totally work. Try it this

way.

Public bBlockEvents As Boolean
Private Sub ComboBox1_DropButtonClick()
Dim s As Date, e As Date, i As Date
If bBlockEvents Then Exit Sub
bBlockEvents = True
s = Range("Start").Value
e = Range("End").Value
sVal = ComboBox1.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
ComboBox1 = sVal
bBlockEvents = False
End Sub

Private Sub ComboBox1_Click()
If bBlockEvents Then Exit Sub
Range("NewStart").Value = ComboBox1.Value
End Sub


--
Regards,
Tom Ogilvy




.



.

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
Chart content to change according to a selection on a combobox Johanna Gronlund Charts and Charting in Excel 1 February 2nd 10 02:05 PM
ComboBox Selection [email protected] uk Excel Discussion (Misc queries) 1 November 14th 08 09:38 PM
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
How do i populate a text box according to selection in combobox? Steve Excel Worksheet Functions 0 April 13th 06 12:40 PM
Combobox not writing value if next selection is same Joe Mathis Excel Programming 1 November 25th 03 11:49 PM


All times are GMT +1. The time now is 11:27 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"