+ Reply to Thread
Results 1 to 8 of 8

Adding text to a table via a macro or userform

  1. #1
    Registered User
    Join Date
    04-24-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    17

    Adding text to a table via a macro or userform

    Heres the scenario. I have created a table with the columns of name surname and gender. There are about 10 names, however i now what to create a button, which when pressed pops up a box (or something similar) which allows me to enter a name surname and gender and automatically creates a new row and enters this data. How can i proceed? (non excel expert so please give details in noob sentences)

    Thanks

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Thumbs up Re: Adding text to a table via a macro or userform

    What is the name of the worksheet on which you want the data to go?
    By creates new row, do you mean, 1) places the data you have entered in the form into the next available (blank row), OR 2) literally insert a row within a populated range?

    If No. 1 above, the answer to your question is to indicate the dynamic target range for each within the 'Submit' event of the form.

    Say A1 is Name Label, B1 is Surname Label, and C1 is Gender Label.
    Now assume you already have names, surnames, and genders spanning 5 rows down (through row 6).

    Your form needs an "ok" or "submit" button, behind which lies the code indicating where the data is to go. In your case, It would look something like this:

    Please Login or Register  to view this content.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Adding text to a table via a macro or userform

    Hi
    You can try this too...

    hmaleki.xlsm

    Regards..
    Click *, if my suggestion helps you. Have a good day!!

  4. #4
    Registered User
    Join Date
    04-24-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Adding text to a table via a macro or userform

    Quote Originally Posted by jraj1106 View Post
    Hi
    You can try this too...

    Attachment 153086

    Regards..
    Hi yea, thats exaclty what i need. How would i apply it to the 'Register' sheet on this spreadsheet?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-24-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Adding text to a table via a macro or userform

    Quote Originally Posted by AlvaroSiza View Post
    What is the name of the worksheet on which you want the data to go?
    By creates new row, do you mean, 1) places the data you have entered in the form into the next available (blank row), OR 2) literally insert a row within a populated range?

    If No. 1 above, the answer to your question is to indicate the dynamic target range for each within the 'Submit' event of the form.

    Say A1 is Name Label, B1 is Surname Label, and C1 is Gender Label.
    Now assume you already have names, surnames, and genders spanning 5 rows down (through row 6).

    Your form needs an "ok" or "submit" button, behind which lies the code indicating where the data is to go. In your case, It would look something like this:

    Please Login or Register  to view this content.
    Hi, Where would i paste this code? Also its number 2, i already have 10 names in cells so this new form would need to create a row and insert the name surname and gender

  6. #6
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Adding text to a table via a macro or userform

    Try this:

    College Markbook (1).xlsm

    Regards..

  7. #7
    Registered User
    Join Date
    04-24-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Adding text to a table via a macro or userform

    Quote Originally Posted by jraj1106 View Post
    Try this:

    Attachment 153203

    Regards..
    Hey
    Thank you, thats exaclty what i need. However how can i access the userform without having to press alt-F11. How can i create a button which will pop up this userform?

  8. #8
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Adding text to a table via a macro or userform


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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