How to create user form using VBA?

BHawk

New Member
Joined
Apr 9, 2010
Messages
8
Hello,

I've allready made an user form, and now I want to do something different.

I want that when I press a command button, it creates a new label(#1) and a text box(#1) on the same form. And when I press the same button again, it creates the same label(#2) under label#1 and a text box(#2) under text box#1

Why I want to do this? Because there is no fixed how many labels and text boxes there will be.

I've searched a little bit around and found this: http://www.tek-tips.com/faqs.cfm?fid=5757 but it doesn't work.

Can anyone help me?
 
Why not use a two column listbox?


Then you could have textbox, a combobox and a command button for user input.

The user enters the data using the textbox and combobox and when they click the command button the data is added in a new row in the listbox.

This would allow the user to enter as much data as they need.

You could even add buttons to delete/edit.
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I suspect you need to change this:
Code:
Me.Controls("text1").Value
to this:
Code:
txt.Value
 
Upvote 0
Thanks. That's a good alternative and I'll go with that if I can't get this to work. I'm dealing with VERY computer illiterate users and have to make input as easy as possible.
 
Upvote 0
I don't see how that's possible with your code. The TXT variable is declared in the same class module and initialised for every class instance.
 
Upvote 0
Wait, I just scrolled to the bottom of your code. Are you clicking the Next button when the error occurs? You can't really use the same class for that button.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top