Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Accessing selection list within a user form

Let me preface this by saying that I'm a novice with user forms.

Since Excel does interesting things with dates (entry of 9/01 results in
9/1/2006), I want to ensure that the dates are entered as desired. I'm
doing this with user form and a selection change event on the cells that have
dates. If someone has a better idea, let me know.

Anyway, I have a list with months in it and a list with years in it.

Month: Dates!A2:A13
Year: Dates!B2:B32

How do I set up a selection list in the user form?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Accessing selection list within a user form

I've figured this out.

"Barb Reinhardt" wrote:

Let me preface this by saying that I'm a novice with user forms.

Since Excel does interesting things with dates (entry of 9/01 results in
9/1/2006), I want to ensure that the dates are entered as desired. I'm
doing this with user form and a selection change event on the cells that have
dates. If someone has a better idea, let me know.

Anyway, I have a list with months in it and a list with years in it.

Month: Dates!A2:A13
Year: Dates!B2:B32

How do I set up a selection list in the user form?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Accessing selection list within a user form

you want one listbox with each month year combination?

With worksheets("Dates")
for each cell in .Range("B2:B32")
for each i = 1 to 12
useform1.listbox1.AddItem format(DateSerial(cell,i,1),"m/yy")
Next
Next
End with

then in you click event for the listbox

Private Sub Listbox1_click()
Dim s as String, iloc as Long, m as String, y as String
s= Listbox1.Value
iloc = Instr(1,s,"/",vbTextcompare)
m = Left(s,iloc-1)
y = "20" & Right(s,len(s)-iloc)
dt = DateSerial(clng(y),clng(m),1)
activecell.Value = dt
activecell.Numberformat = "m/yy"
End Sub

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote:

Let me preface this by saying that I'm a novice with user forms.

Since Excel does interesting things with dates (entry of 9/01 results in
9/1/2006), I want to ensure that the dates are entered as desired. I'm
doing this with user form and a selection change event on the cells that have
dates. If someone has a better idea, let me know.

Anyway, I have a list with months in it and a list with years in it.

Month: Dates!A2:A13
Year: Dates!B2:B32

How do I set up a selection list in the user form?

Thanks

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
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
Generate a value from user selection in list box. Sol Excel Discussion (Misc queries) 2 September 8th 06 09:03 PM
Which User Form Listbox selection just checked? Don Wiss Excel Programming 3 October 27th 05 01:52 AM
User Form List Box Hank Hendrix Excel Programming 0 May 25th 04 10:22 AM
User Form / List Box Rockee052 Excel Programming 0 December 28th 03 04:55 AM


All times are GMT +1. The time now is 03:21 AM.

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

About Us

"It's about Microsoft Excel"