+ Reply to Thread
Results 1 to 7 of 7

userform testbox to create number of textbox to another userform

  1. #1
    Forum Contributor
    Join Date
    10-18-2015
    Location
    manila, philippines
    MS-Off Ver
    MS Office 2010
    Posts
    186

    userform testbox to create number of textbox to another userform

    Hi Experts!

    I am creating a form where there will be multiple userforms. So I have "userform1", textbox1 is where I'll put a number, say "10" for example, is it possible to get to "userform2" and have 10 textboxes? and if "5" is entered from "userform1", 5 textboxes will be created in "userform2"?

  2. #2
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: userform testbox to create number of textbox to another userform

    Hi Markus,

    The following code will add textbox(s) to a second userform from the number entered in a textbox on the first userform. The code assumes the following but you can change them:

    FIRST USERFORM:
    Name: arbitrary
    one textbox name: TextBox1
    one commandbutton name: CommandButton1

    SECOND USERFORM:
    Name: UserForm2
    Can include any objects you like except textboxes named "TextBox1, TextBox2, etc."


    Please Login or Register  to view this content.
    You can change the parameters (height, width, left, top, value, naming convention, etc). Remember that the textboxes are created at runtime and will not be prest after the code is finished running. Therefore, you want to initiate Userform2 in the code from commandButton1 on UserForm1 and continue running your code from the second userform in a continuous flow.

    If possible, a better approach is to have all the textboxes with .visible = FALSE on userform2 at design time and set their .visibility to TRUE as needed.

    HTH,
    Maud

  3. #3
    Forum Contributor
    Join Date
    10-18-2015
    Location
    manila, philippines
    MS-Off Ver
    MS Office 2010
    Posts
    186

    Re: userform testbox to create number of textbox to another userform

    what do you mean?

  4. #4
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: userform testbox to create number of textbox to another userform

    I had verbiage that was being picked up as an HTML tag. I removed it and it enabled me to post....see above.

    Maud

  5. #5
    Forum Contributor
    Join Date
    10-18-2015
    Location
    manila, philippines
    MS-Off Ver
    MS Office 2010
    Posts
    186

    Re: userform testbox to create number of textbox to another userform

    thank you so much Maudibe! Your code worked like a charm. One more thing, is there a way that userform2 can have like 40 textboxes and have 4 columns to fit them (10 textbox per column).

  6. #6
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: userform testbox to create number of textbox to another userform

    Markus,

    Here is the code revised so that multiple column of textboxes can be created. Like the previous code Userform1 must have a textbox called Textbox1 and a button called CommandButton1. Userform2 can be blank or have any objects you please as long as they are not named Textbox1, TextBox2, etc..

    **NEW**
    when you launch Userform1, in Textbox1 enter the number of total textboxes, a "/", and the number of columns (eg. 34/4) which yield 34 total textboxes in 4 columns. The code auto-arranges the remainder of the textboxes. The height and width of the form are automatically calculated using the number of columns, width, and height of the textboxes.

    HTH,
    Maud

    Add Textboxes.png

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-18-2015
    Location
    manila, philippines
    MS-Off Ver
    MS Office 2010
    Posts
    186

    Re: userform testbox to create number of textbox to another userform

    I totally appreciate your time for helping me on this, it works perfectly! now I just have to figure out if it's possible to have all the entries from all my userforms be transferred to just one worksheet.

  8. #8
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: userform testbox to create number of textbox to another userform

    This will do it:


    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Testbox Multiline Userform
    By calvinle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-01-2015, 02:53 PM
  2. Replies: 23
    Last Post: 07-12-2014, 07:09 PM
  3. [SOLVED] Add 1 to the last number in a textbox in a userform
    By skip2mylew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2014, 07:45 AM
  4. [SOLVED] Excel 2007, Userform Textbox Date Format and Calendar Control Userform
    By riffology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2014, 06:18 PM
  5. Want to create a leave comment textbox with userform
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2013, 09:35 PM
  6. Userform Textbox updating a another userform textbox (im stuck!!)
    By wapwap in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-31-2011, 02:56 PM
  7. Auto scroll contents of Userform testbox
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-01-2009, 08:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1