ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to create a dynamic Userform via VBA (https://www.excelbanter.com/excel-programming/285233-how-create-dynamic-userform-via-vba.html)

SuperJas

How to create a dynamic Userform via VBA
 
Hi,

I'd like to create a dynamic userform which can vary the number of inputs depending on the user. A userform will be displayed with 1 textbox to enter their car model. There will be a command button that will allow the user to 'add' more textboxes if they have more cars. Of course I will be placing a limit on the number of cars a person can enter! =)

So my first question would be: is there code which will allow me to resize the userform (eg widen by x lines/pixels/whatever) as the user adds textboxes?

My second question is: is there a relatively simple piece of code which will allow me to add a textbox, say, directly below the one above (maybe with some space in between)?

Thanks very much.

Tom Ogilvy

How to create a dynamic Userform via VBA
 
Userform has height and width properties.

Look in help at controls.Add

the bottom of the first textbox

sepval = 10
Textbox2.Top = Textbox1.Top + textbox1.Height + sepval

--
Regards,
Tom Ogilvy


SuperJas wrote in message
...
Hi,

I'd like to create a dynamic userform which can vary the number of inputs

depending on the user. A userform will be displayed with 1 textbox to enter
their car model. There will be a command button that will allow the user to
'add' more textboxes if they have more cars. Of course I will be placing a
limit on the number of cars a person can enter! =)

So my first question would be: is there code which will allow me to resize

the userform (eg widen by x lines/pixels/whatever) as the user adds
textboxes?

My second question is: is there a relatively simple piece of code which

will allow me to add a textbox, say, directly below the one above (maybe
with some space in between)?

Thanks very much.





All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com