PDA

View Full Version : Solved: Command button to add items on Userform



malik641
12-09-2005, 11:45 AM
This may be a stretch, but....

I'm trying to make a userform to filter out data using Advanced Filter. The thing is, the users that will be using this workbook are not too familiar with using the Advanced Filter. So I would like to make it easier for them to use and this way would be a little more neat because there are a lot of criteria headings to choose from and I want the user to be able to use multiple criteria for better flexibility.

Let's say I have a button "Add Criteria" and a combo box with a list of the criteria headings in it. Some of the criteria require text (Sponsor names) and most require dates (either start and end, or a particular month/year). What I want is when a user selects the criteria heading to add, on the userform, either combo boxes (for dates) or a text box (for string criteria) to the right of the Criteria heading combo box based on the selection they made.

And if the user wants to add more criteria, they would press the "Add Criteria" button and the userform would then stretch vertically to make room for the new Criteria Heading Combo Box...then once the user selects an item from the combo box it will add the items as stated in the last paragraph.

I also would like a limit to how many Criteria Heading Combo Boxes can be added (I guess...maybe...8 or so http://vbaexpress.com/forum/images/smilies/102.gif )

Should I even bother? This was just a quick thought I had and I'm not even sure if I should tie my time up writing all the code for this. Not to mention I only have 2 weeks to finish this project (with others as well) because I'm moving to Florida after Christmas http://vbaexpress.com/forum/images/smilies/045.gif

Tommy
12-09-2005, 02:55 PM
Hi Joseph,

The attached has a command button to add combobox or textbox depending on which option button is picked. Optionbutton1 will add a combobox, Optionbutton2 will add the textbox. If either is off the form the form is resized.
You will need to add a name and reference the control as Userform1!nameofcontrol.text

HTH

malik641
12-12-2005, 06:31 AM
Thanks Tommy, just what I was looking for :thumb


I actually ended up creating list boxes with multiple selection, but I know I will need this code for the future. So thanks again :yes



Solved!