+ Reply to Thread
Results 1 to 22 of 22

Userform Macro to Use Textbox input to Generate blank rows.

  1. #1
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Userform Macro to Use Textbox input to Generate blank rows.

    I have a userform with 16 Textboxes Named "Text1" through "Text16". What I am trying to do is apply code that if there is content in the textbox it generates a new row after row15 and inputs the text in cellA of that row. Ex. "Text1" = JOE "Text2" = TONY......Hit Commandbutton1 on userform. It inserts Row16 puts "JOE" in A16.....then sequentially it inserts Row17 puts "TONY" in A17.

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi Jared

    try this attached file and let me know
    Attached Files Attached Files
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi, jaredmccullough,

    I sort of dislike to havbe a large number of Textboxes for running a job like this, IŽd go with 1 TextBox and use a separator there like | to split the contents.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Quote Originally Posted by Naveed Raza View Post
    Hi Jared

    try this attached file and let me know
    Naveed,

    Thank you for the reply. It is very close to the desired output but as I think it will be hard to get the issues across through text I have instead attached an example file of my workbook. To get to the Userform of concern: Use the Commandbutton on the first worksheet, Select the commandbutton on that Userform that states "Build New Template", Hit Submit on the "Audit Information" userform no need to fill anything in, The subsequent Userform (Useform2) titled "Audit Categories" is the one of concern. Type a number in the first Textbox and it will populate with a certain number of textboxes. If you look the "Textboxes" that appear beside the "Category" labels are the one of concern. There are up to 16 categories (i.e. Textboxes)for the user to input. For each of those textboxes that a category name is filled in for I am looking that a Row is generated below row 15 (in sequential order) and the Text is tranlated into the generated row. Just take a look at the file and get back with questions.

    Forum Example.xlsm

  5. #5
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Quote Originally Posted by HaHoBe View Post
    Hi, jaredmccullough,

    I sort of dislike to havbe a large number of Textboxes for running a job like this, IŽd go with 1 TextBox and use a separator there like | to split the contents.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Holger thank you for the reply see response above with workbook and instructions to get to userform. I think originally the desired output may not have been understood.

    Jared

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi, Jared,

    you should make better use of naming the UserForms adn giving adequate caption sfor tehse.

    Behind UserForm1:
    Please Login or Register  to view this content.
    Behind UserForm2:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Holger,

    Thank you for the reply. I like the changes you have made to the naming of the first sheet as it will eliminate having the same "New Template" issues. I think there maybe some confusion on the second Submitform2 output. The code I originally had where it added the cells to A7:A14 and D7:D14 was intended to be included with the "Adding Row" Function. The "Adding Rows" portion you put in worked partially as desired. Instead of it moving over and adding values in in columnD after the 8th textbox I was looking for it to continue to just add rows for all 16 textboxes. Desired Output: Add 16 categories to appropriate cells from A7:A14 and D7:D14 as well as add a row for each. If you look at the newly updated code I have changed it around the only issue now is that category 9 and on goes to cell D16 and up. So basically what you have now was set up in the previous code to go in A7:A14 and D7:D14 what you have added works till "Category8" but from Category9 on is supposed to continue to add rows. I know that is kinda of confusing but I hope you will see in the workbook. Bascially instead of adding in D16 and on for Textboxes "Text9" through "Text16" i want them to continue to add rows in columnA.

    Forum Example.xlsm

  8. #8
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Holger,

    See active Worksheet ARG-130829. If you see A7 = Application and Row15 = Application. This is what I am trying to achieve for all 16 categories. My next goal will then be to create some hyperlink that when the user clicks cell A7 "Application" it will take them to them to Row15. This is important because category16 may be 100s of cells down so my intent would be the click D14 where "Category16" will be and it will take them to the Row where "Category16" was placed.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi, Jared,

    without looking at the workbook or the code I guess the solution might be to change the code to
    Please Login or Register  to view this content.
    or if you want the same area being filled on every run of the code
    Please Login or Register  to view this content.
    Ciao,
    Holger

  10. #10
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Holger the first application seems to work as desired. I now am looking to create a hyperlink between the cell the "Textbox" is inserted in and the row generated for it. Ex. "Text4" goes to cell A10 and will generate the 4th row in the sequence. I want the user to be able to click cell A10 and it take them to its respective row. The following is the current code I have so far

    Please Login or Register  to view this content.
    Last edited by jaredmccullough; 03-31-2014 at 06:54 AM.

  11. #11
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    I forgot to mention some important information. What I am meaning is that there is a freeze pane after Row15 on the worksheet. What my desired outcome would be is that when the user selects the category from cell that the textbox is inserted in (The first part of the code). The macro will bring (Scroll) that matching header that was created to the meet the freeze pane. The point of this is that the user can pull up the desired category without having to scroll through what could be a large quantity of cells.

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi, Jared,

    I neither understand why would need a direct writing as well as repeat it in a loop nor what you are after now.

    Ciao,
    Holger

  13. #13
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Holger,

    Modified Please see 2 comments below
    Last edited by jaredmccullough; 03-31-2014 at 02:51 PM.

  14. #14
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Holger,

    If you view the example Workbook I have attached and look at the WS titled "ARG-130829" you can maybe understand the concept a little better. If you see the gray cells A7:A14 and D7:D14 they are match the header rows below Row 15. What I am trying to do is create a macro that say when the user clicks on A10 "Process Hazard Analysis" it brings Row54 up to the top of the Freeze Pane. How the rows are generated are through Userform2. The user inputs a heading using the "Text1" through "Text16" textboxes and a number of questions using "Question1" through "Question 16" textboxes.

    The headings (Text1-Text16) generate a Row and the # of Question (Question1-Question16) generate a number of rows between the headings and use the category number to generate a numbering system (i.e. 1.001, 1.002, 2.002, etc....)

    Say the user puts in Text1 = JON and Question1 = 4 and Text2 = JIM and Question2 = 8 that would mean that Row16 = Jon, Row17-20 would be 1.001 through 1.004, Row21 would be JIM and Row22-28 would be 2.002 through 2.008

  15. #15
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    A category is a combination of Textboxes so Category1 is textboxes "Text1"/"Question1", Category2 is textboxes "Text2"/"Question2"...etc

    The desired output would be that for each category (using category1 and category2 as an example):

    Text1 = Cell A7
    Text1 = Generate Row16 Insert Text in A16
    Text1 = Create link between A7 and A16 so when user hits A7 it scrolls A16 to top (Freeze Pane at Row 15)
    Question1 = Generate Rows Based on user input
    Question1 = Generate item numbers in column A (1.000+) based on number of questions

    Text2 = Cell A8
    Text2 = Generate Row in next availalbe
    Text2 = Create link between A8 and Generated Row so when user hits A8 it scrolls the “Header Row” to top (Freeze Pane at Row 15)
    Question2 = Generate Rows Based on user input
    Question2 = Generate item numbers in column A (2.000+) based on number of questions
    Last edited by jaredmccullough; 03-31-2014 at 02:32 PM.

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi, Jared,

    regarding the code for submitting:
    Please Login or Register  to view this content.
    What should happen if QuestionX is left unfilled?

    Ciao,
    Holger

  17. #17
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    ***********************

  18. #18
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.



    Holger,

    It seems to work very well for insertion of rows. In regards to your question if QuestionX is left unfiled my intentions would be just to assume a value of "0" and insert no rows. If it would be at all possible maybe at the end of its cycle notify the user that no questions were added for the TextX that the QuestionX correlates with. As for the TextX textboxes (which are used as header rows) I was wondering if we could adjust some formatting issues. I was hoping to get the text rows generated to be colorfill "Gray" and there are text alignment issues that when the text is inserted in the row it aligns in columnA and runs off the left side of the page do you know how to correct this?

    Thanks for the help,

    Jared

    EDIT: See WS "ARG-130829" for an example of the formatting of these cells.
    Last edited by jaredmccullough; 04-01-2014 at 12:25 PM.

  19. #19
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi, Jared,

    I wonder if you ever heard of a featiure liek the macro recorder which would supply a base for getting code for a couple of questions.

    Please Login or Register  to view this content.
    Ciao,
    Holger

  20. #20
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Quote Originally Posted by HaHoBe View Post
    Hi, Jared,


    Holger
    Holger,

    Formatting and stuff works well. Only issue is if user forgets to put in Question Number it comes up with a "Run-Time Error 13" Type Mismatch on line

    lngMax = Controls("Question" & lngCounter).Value

    Any clue as to why (this basically negates the MSG because it does not reach that far)

    Again thanks for the help.

    Jared

  21. #21
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Hi, Jared,

    maybe adjust the design by yourself in filling the Textboxes with 0 in designer mode or only allow the code to run when the corresponding textboxes are both filled? This is a queation of design in my view not only of coding.

    Instead of
    Please Login or Register  to view this content.
    maybe use
    Please Login or Register  to view this content.
    Ciao,
    Holger

  22. #22
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Userform Macro to Use Textbox input to Generate blank rows.

    Quote Originally Posted by HaHoBe View Post
    Hi, Jared,

    maybe adjust the design by yourself in filling the Textboxes with 0 in designer mode or only allow the code to run when the corresponding textboxes are both filled? This is a queation of design in my view not only of coding.

    Instead of
    Please Login or Register  to view this content.
    maybe use
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Holger,

    Thanks for the suggestions and everything seems to work as intended. There is 1 function with this I am still trying to achieve. I have a "Freeze Pane" on Row15 so that row 15 and above remain locked. If you will view the following code at the end what is happening is that your "Insert Rows" function is working at the same time as a categories section is being populated. (Categories section is A8:A15 and D8:D15) Where "Text1" is going to A8 and sequentially from there until "Text16" is going to D15. What I was trying to create is either some kind of link or else worksheet code that when the user clicks the category from the Category Section (as defined earlier) that the header matching this category will scroll to the top (Meaning against the freeze pane).

+ 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] Pass Value of combobox selected in Userform as input to textbox of other userform
    By Pradeepg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2013, 10:32 AM
  2. input the value of a Combobox and a textbox to a TEXTBOX directly from a userform
    By Gordonhk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2013, 03:25 PM
  3. how to generate serial number on a textbox in userform
    By minionrush in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2013, 05:12 AM
  4. Use textbox input and VLookup to update another textbox on same userform
    By gcoug in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2011, 10:39 AM
  5. [SOLVED] checking input on a textbox in userform to be a %
    By Jean-Pierre D via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-25-2005, 07:05 PM

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