PC Review


Reply
Thread Tools Rate Thread

Accessing selection list within a user form

 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      16th Oct 2006
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 With Quote
 
 
 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      16th Oct 2006
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

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Oct 2006
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two list-box selection on a form ascagnel Microsoft Access Forms 2 18th Jul 2008 05:29 PM
Combo box list selection based on earlier selection by user MSA Microsoft Access Form Coding 2 27th Feb 2008 05:00 PM
How do I fill a cell in a user form from a selection on same form? =?Utf-8?B?VGVycnkgVGlwc3k=?= Microsoft Excel Misc 4 11th Jun 2007 02:59 PM
Load form If certain selection in list box =?Utf-8?B?Zm9yZHJ1bGVzMDE=?= Microsoft Access 2 8th Jun 2007 02:08 AM
Generate a value from user selection in list box. =?Utf-8?B?U29s?= Microsoft Excel Misc 2 8th Sep 2006 09:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:11 PM.