userform combobox lists

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Userform combobox lists

Userform combobox lists

resolvedResolved · Low Priority · Version 2007

Edited on Sun 23 Jun 2013, 10:31

Louisa has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course

Userform combobox lists

Hi,

I am working my way through userforms and have two queries. Thanks in advance for your help on these am stuck.

Firstly I have a date which is NOW in excel which I am linking to the userform. I have it formated in excel as dd/mm/yy and want the same in the userform.

I can do this for strings but want to keep it as date / double. How do I do that?

Also how do you get the pointer to start in the first box (text or combo)?

Thanks

I have edited this as have sorted out the coding issues I was having.

RE: Userform combobox lists

Hi Louisa

Thanks for getting in touch. With regards to your dates, it is best to use the Format function to control them. You could then employ it in the Initialize event.

To create an Initialize event, double click an empty area of your userform, then change the drop-down to the top-right of the VBE to "Initialize". Code entered here will be executed when the form loads.

If you had a label called "Label1" and your date was in cell A1, then you could format it like this:

Label1.Caption = Format(Range("A1"), "dd/mm/yyyy")

With regards to controlling the pointer, the order is controlled by a property called TabIndex. This is in the order that the controls were created. Over time controls are deleted and moved and the order changes. To reset this again put code like this in the Initialize event:

TextBox1.TabIndex = 1
ComboBox1.TabIndex = 2
CommandButton1.TabIndex = 3

And keep adding indexes as required.

I hope this helps.

Kind regards

Gary Fenn
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Userform combobox lists

Hi,

They both work perfectly thanks. Mine was a textbox so the code I used was:

TradeDate = Format(Sheets("front sheet").Range("E11"), "dd/mm/yyyy")

Thank you.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


Server loaded in 0.09 secs.